xref: /freebsd/share/man/man5/style.mdoc.5 (revision 5e077e08ef87126765b5a818def6cb99314ab192)
113bf4d9eSMateusz Piotrowski.\"
213bf4d9eSMateusz Piotrowski.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD
313bf4d9eSMateusz Piotrowski.\"
4*5e077e08SMateusz Piotrowski.\" Copyright (c) 2018-2021 Mateusz Piotrowski <0mp@FreeBSD.org>
513bf4d9eSMateusz Piotrowski.\"
613bf4d9eSMateusz Piotrowski.\" Redistribution and use in source and binary forms, with or without
713bf4d9eSMateusz Piotrowski.\" modification, are permitted provided that the following conditions
813bf4d9eSMateusz Piotrowski.\" are met:
913bf4d9eSMateusz Piotrowski.\" 1. Redistributions of source code must retain the above copyright
1013bf4d9eSMateusz Piotrowski.\"    notice, this list of conditions and the following disclaimer.
1113bf4d9eSMateusz Piotrowski.\" 2. Redistributions in binary form must reproduce the above copyright
1213bf4d9eSMateusz Piotrowski.\"    notice, this list of conditions and the following disclaimer in the
1313bf4d9eSMateusz Piotrowski.\"    documentation and/or other materials provided with the distribution.
1413bf4d9eSMateusz Piotrowski.\"
1513bf4d9eSMateusz Piotrowski.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1613bf4d9eSMateusz Piotrowski.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1713bf4d9eSMateusz Piotrowski.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1813bf4d9eSMateusz Piotrowski.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1913bf4d9eSMateusz Piotrowski.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2013bf4d9eSMateusz Piotrowski.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2113bf4d9eSMateusz Piotrowski.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2213bf4d9eSMateusz Piotrowski.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2313bf4d9eSMateusz Piotrowski.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2413bf4d9eSMateusz Piotrowski.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2513bf4d9eSMateusz Piotrowski.\" SUCH DAMAGE.
2613bf4d9eSMateusz Piotrowski.\"
2713bf4d9eSMateusz Piotrowski.\" $FreeBSD$
2813bf4d9eSMateusz Piotrowski.\"
29*5e077e08SMateusz Piotrowski.Dd December 3, 2021
3013bf4d9eSMateusz Piotrowski.Dt STYLE.MDOC 5
3113bf4d9eSMateusz Piotrowski.Os
3213bf4d9eSMateusz Piotrowski.Sh NAME
3313bf4d9eSMateusz Piotrowski.Nm style.mdoc
3413bf4d9eSMateusz Piotrowski.Nd
3513bf4d9eSMateusz Piotrowski.Fx
3613bf4d9eSMateusz Piotrowski.Xr mdoc 7
3713bf4d9eSMateusz Piotrowskifile style guide
3813bf4d9eSMateusz Piotrowski.Sh DESCRIPTION
3913bf4d9eSMateusz PiotrowskiThis file specifies the preferred style for manual pages in the
4013bf4d9eSMateusz Piotrowski.Fx
4113bf4d9eSMateusz Piotrowskisource tree.
42e84f6455SMateusz Piotrowski.Ss Code Examples
4313bf4d9eSMateusz Piotrowski.Bl -dash -width ""
4413bf4d9eSMateusz Piotrowski.It
4513bf4d9eSMateusz PiotrowskiUse literal formatting for examples and literal shell commands, e.g.:
4613bf4d9eSMateusz Piotrowski.Bd -literal -offset indent
4713bf4d9eSMateusz PiotrowskiThen run
48*5e077e08SMateusz Piotrowski\&.Ql make install clean .
4913bf4d9eSMateusz Piotrowski.Ed
5013bf4d9eSMateusz Piotrowski.Pp
5113bf4d9eSMateusz Piotrowskiwhich renders as:
5213bf4d9eSMateusz Piotrowski.Bd -filled -offset indent
5313bf4d9eSMateusz PiotrowskiThen run
54*5e077e08SMateusz Piotrowski.Ql make install clean .
5513bf4d9eSMateusz Piotrowski.Ed
5613bf4d9eSMateusz Piotrowski.Pp
5713bf4d9eSMateusz PiotrowskiThe incorrect way would be to use macros like
5813bf4d9eSMateusz Piotrowski.Sy \&Nm
5913bf4d9eSMateusz Piotrowskito stylize the command invocation:
6013bf4d9eSMateusz Piotrowski.Bd -literal -offset indent
6113bf4d9eSMateusz PiotrowskiThen run
62*5e077e08SMateusz Piotrowski\&.Ql Nm make Cm install Cm clean .
6313bf4d9eSMateusz Piotrowski.Ed
6413bf4d9eSMateusz Piotrowski.Pp
6513bf4d9eSMateusz Piotrowskiwhich renders as:
6613bf4d9eSMateusz Piotrowski.Bd -filled -offset indent
6713bf4d9eSMateusz PiotrowskiThen run
68*5e077e08SMateusz Piotrowski.Ql Nm make Cm install Cm clean .
6913bf4d9eSMateusz Piotrowski.Ed
70*5e077e08SMateusz Piotrowski.It
71*5e077e08SMateusz PiotrowskiThe
72*5e077e08SMateusz Piotrowski.Sy \&Ql
73*5e077e08SMateusz Piotrowskimacro is the preferred macro for formatting literal inline fragments.
74*5e077e08SMateusz PiotrowskiHistorically,
75*5e077e08SMateusz Piotrowski.Sy \&Dq \&Li
76*5e077e08SMateusz Piotrowskiwas the preferred way before the deprecation of
77*5e077e08SMateusz Piotrowski.Sy \&Li .
7813bf4d9eSMateusz Piotrowski.El
79e84f6455SMateusz Piotrowski.Ss EXAMPLES Section
80e84f6455SMateusz Piotrowski.Bl -dash -width ""
81e84f6455SMateusz Piotrowski.It
82e84f6455SMateusz PiotrowskiFormat the
83e84f6455SMateusz Piotrowski.Sx EXAMPLES
84e84f6455SMateusz Piotrowskisection in the following way:
85e84f6455SMateusz Piotrowski.Bd -literal -offset indent
86e84f6455SMateusz Piotrowski\&.Bl -tag -width 0n
87ca588aedSMateusz Piotrowski\&.It Sy Example 1\\&: No Doing Something
88e84f6455SMateusz Piotrowski\&.Pp
89e84f6455SMateusz PiotrowskiThe following command does something.
90e84f6455SMateusz Piotrowski\&.Bd -literal -offset 2n
91e84f6455SMateusz Piotrowski\&.Li # Ic make -VLEGAL
92e84f6455SMateusz Piotrowski\&.Ed
93ca588aedSMateusz Piotrowski\&.It Sy Example 2\\&: No Doing Something Different
94e84f6455SMateusz Piotrowski\&.Pp
95e84f6455SMateusz PiotrowskiThe following command does something different.
96e84f6455SMateusz Piotrowski\&.Bd -literal -offset 2n
97e84f6455SMateusz Piotrowski\&.Li # Ic bectl list
98e84f6455SMateusz Piotrowski\&.Ed
99e84f6455SMateusz Piotrowski\&.Pp
100e84f6455SMateusz PiotrowskiIt is good to know this command.
101e84f6455SMateusz Piotrowski\&.El
102e84f6455SMateusz Piotrowski.Ed
103e84f6455SMateusz Piotrowski.Pp
104e84f6455SMateusz Piotrowskiwhich renders as:
105e84f6455SMateusz Piotrowski.Bd -filled -offset indent
106e84f6455SMateusz Piotrowski.Bl -tag -width 0n
107e84f6455SMateusz Piotrowski.It Sy Example 1\&: No Doing Something
108e84f6455SMateusz Piotrowski.Pp
109e84f6455SMateusz PiotrowskiThe following command does something.
110e84f6455SMateusz Piotrowski.Bd -literal -offset 2n
111e84f6455SMateusz Piotrowski.Li # Ic make -VLEGAL
112e84f6455SMateusz Piotrowski.Ed
113e84f6455SMateusz Piotrowski.It Sy Example 2\&: No Doing Something Different
114e84f6455SMateusz Piotrowski.Pp
115e84f6455SMateusz PiotrowskiThe following command does something different.
116e84f6455SMateusz Piotrowski.Bd -literal -offset 2n
117e84f6455SMateusz Piotrowski.Li # Ic bectl list
118e84f6455SMateusz Piotrowski.Ed
119e84f6455SMateusz Piotrowski.Pp
120e84f6455SMateusz PiotrowskiIt is good to know this command.
121e84f6455SMateusz Piotrowski.El
122e84f6455SMateusz Piotrowski.Ed
123e84f6455SMateusz Piotrowski.El
124e84f6455SMateusz Piotrowski.Ss Synopsis Formatting
12513bf4d9eSMateusz Piotrowski.Bl -dash -width ""
12613bf4d9eSMateusz Piotrowski.It
12713bf4d9eSMateusz PiotrowskiDo not put whitespace between alternative parameters separated with a pipe
12813bf4d9eSMateusz Piotrowski.Pq Dq | ,
12913bf4d9eSMateusz Piotrowskie.g.:
13013bf4d9eSMateusz Piotrowski.Bd -literal -offset indent
13113bf4d9eSMateusz Piotrowski\&.Cm compression Cm on Ns | Ns Cm off
13213bf4d9eSMateusz Piotrowski\&.Cm install Fl -all Ns | Ns Ar portname Ar ...
13313bf4d9eSMateusz Piotrowski.Ed
13413bf4d9eSMateusz Piotrowski.Pp
13513bf4d9eSMateusz Piotrowskiwhich in the SYNOPSIS section is rendered as:
13613bf4d9eSMateusz Piotrowski.Bd -unfilled -offset indent
13713bf4d9eSMateusz Piotrowski.Cm compression Cm on Ns | Ns Cm off
13813bf4d9eSMateusz Piotrowski.Cm install Fl -all Ns | Ns Ar portname Ar ...
13913bf4d9eSMateusz Piotrowski.Ed
14013bf4d9eSMateusz Piotrowski.It
14113bf4d9eSMateusz PiotrowskiUse
14213bf4d9eSMateusz Piotrowski.Sy \&Cm
14313bf4d9eSMateusz Piotrowskito stylize characters that are command modifiers
14413bf4d9eSMateusz Piotrowski.Po e.g.,
14513bf4d9eSMateusz Piotrowski.Dq \&, ,
14613bf4d9eSMateusz Piotrowski.Dq @
14713bf4d9eSMateusz Piotrowskior
14813bf4d9eSMateusz Piotrowski.Dq "="
14913bf4d9eSMateusz Piotrowski.Pc .
15013bf4d9eSMateusz PiotrowskiFor example:
15113bf4d9eSMateusz Piotrowski.Bd -literal -offset indent
15213bf4d9eSMateusz Piotrowski\&.Sm off
15313bf4d9eSMateusz Piotrowski\&.Fl -meet Cm = Ar who Oo Cm \&, Ar who " " Ar "..." Oc Cm @ Ar where
15413bf4d9eSMateusz Piotrowski\&.Sm on
15513bf4d9eSMateusz Piotrowski.Ed
15613bf4d9eSMateusz Piotrowski.Pp
15713bf4d9eSMateusz Piotrowskiwhich renders as:
15813bf4d9eSMateusz Piotrowski.Bd -filled -offset indent
15913bf4d9eSMateusz Piotrowski.Sm off
16013bf4d9eSMateusz Piotrowski.Fl -meet Cm = Ar who Oo Cm \&, Ar who " " Ar "..." Oc Cm @ Ar where
16113bf4d9eSMateusz Piotrowski.Sm on
16213bf4d9eSMateusz Piotrowski.Ed
16313bf4d9eSMateusz Piotrowski.Pp
16413bf4d9eSMateusz Piotrowskiinstead of:
16513bf4d9eSMateusz Piotrowski.Bd -literal -offset indent
16613bf4d9eSMateusz Piotrowski\&.Sm off
16713bf4d9eSMateusz Piotrowski\&.Fl -meet No = Ar who Oo , Ar who " " Ar "..." Oc @ Ar where
16813bf4d9eSMateusz Piotrowski\&.Sm on
16913bf4d9eSMateusz Piotrowski.Ed
17013bf4d9eSMateusz Piotrowski.Pp
17113bf4d9eSMateusz Piotrowskiwhich would render as:
17213bf4d9eSMateusz Piotrowski.Bd -filled -offset indent
17313bf4d9eSMateusz Piotrowski.Sm off
17413bf4d9eSMateusz Piotrowski.Fl -meet No = Ar who Oo , Ar who " " Ar "..." Oc @ Ar where
17513bf4d9eSMateusz Piotrowski.Sm on
17613bf4d9eSMateusz Piotrowski.Ed
17713bf4d9eSMateusz Piotrowski.Pp
17813bf4d9eSMateusz PiotrowskiIt is important to realize that in the correct example,
17913bf4d9eSMateusz Piotrowski.Dq \&, ,
18013bf4d9eSMateusz Piotrowski.Dq @
18113bf4d9eSMateusz Piotrowskiand
18213bf4d9eSMateusz Piotrowski.Dq =
18313bf4d9eSMateusz Piotrowskiare stylized with
18413bf4d9eSMateusz Piotrowski.Sy \&Cm .
18513bf4d9eSMateusz PiotrowskiAt the same time, the square brackets
18613bf4d9eSMateusz Piotrowski.Pq Dq "[]"
18713bf4d9eSMateusz Piotrowskiare not stylized as they do not belong to the syntax of the
18813bf4d9eSMateusz Piotrowski.Fl -meet
18913bf4d9eSMateusz Piotrowskiflag.
19013bf4d9eSMateusz Piotrowski.El
19113bf4d9eSMateusz Piotrowski.Ss Quoting
19213bf4d9eSMateusz Piotrowski.Bl -dash -width ""
19313bf4d9eSMateusz Piotrowski.It
19413bf4d9eSMateusz PiotrowskiUse the
19513bf4d9eSMateusz Piotrowski.Sy \&Dq
19613bf4d9eSMateusz Piotrowski.Pq Do Dc
19713bf4d9eSMateusz Piotrowskimacro
19813bf4d9eSMateusz Piotrowskifor quoting.
19913bf4d9eSMateusz PiotrowskiUse the
20013bf4d9eSMateusz Piotrowski.Sy \&Sq
20113bf4d9eSMateusz Piotrowski.Pq So Sc
20213bf4d9eSMateusz Piotrowskimacro for quoting inside quotes.
20313bf4d9eSMateusz PiotrowskiThe use of the
20413bf4d9eSMateusz Piotrowski.Sy \&Qq
20513bf4d9eSMateusz Piotrowski.Pq Qo Qc
20613bf4d9eSMateusz Piotrowskimacro is usually not necessary.
20713bf4d9eSMateusz Piotrowski.El
20813bf4d9eSMateusz Piotrowski.Ss Variables
20913bf4d9eSMateusz Piotrowski.Bl -dash -width ""
21013bf4d9eSMateusz Piotrowski.It
21113bf4d9eSMateusz PiotrowskiUse
21213bf4d9eSMateusz Piotrowski.Sy \&Va
2136e33d37fSMateusz Piotrowskiinstead of
21413bf4d9eSMateusz Piotrowski.Sy \&Dv
21513bf4d9eSMateusz Piotrowskifor
21613bf4d9eSMateusz Piotrowski.Xr sysctl 8
21713bf4d9eSMateusz Piotrowskivariables like
21813bf4d9eSMateusz Piotrowski.Va kdb.enter.panic .
21913bf4d9eSMateusz Piotrowski.It
22013bf4d9eSMateusz PiotrowskiUse the angle brackets
22113bf4d9eSMateusz Piotrowski.Sy \&Aq
22213bf4d9eSMateusz Piotrowski.Pq Dq "<>"
22313bf4d9eSMateusz Piotrowskimacro
22413bf4d9eSMateusz Piotrowskifor arguments
22513bf4d9eSMateusz Piotrowski.Pq Sy \&Ar
22613bf4d9eSMateusz Piotrowskiwhen they are mixed with similarly stylized macros like
22713bf4d9eSMateusz Piotrowski.Sy \&Pa
22813bf4d9eSMateusz Piotrowskior
22913bf4d9eSMateusz Piotrowski.Sy \&Va ,
23013bf4d9eSMateusz Piotrowskie.g.:
23113bf4d9eSMateusz Piotrowski.Bd -literal -offset indent
23213bf4d9eSMateusz Piotrowski\&.Va critical_filesystems_ Ns Aq Ar type
23313bf4d9eSMateusz Piotrowski.Ed
23413bf4d9eSMateusz Piotrowski.Pp
23513bf4d9eSMateusz Piotrowskiwhich renders as:
23613bf4d9eSMateusz Piotrowski.Bd -filled -offset indent
23713bf4d9eSMateusz Piotrowski.Va critical_filesystems_ Ns Aq Ar type
23813bf4d9eSMateusz Piotrowski.Ed
23913bf4d9eSMateusz Piotrowski.Pp
24013bf4d9eSMateusz Piotrowskiinstead of:
24113bf4d9eSMateusz Piotrowski.Bd -literal -offset indent
24213bf4d9eSMateusz Piotrowski\&.Va critical_filesystems_ Ns Ar type
24313bf4d9eSMateusz Piotrowski.Ed
24413bf4d9eSMateusz Piotrowski.Pp
24513bf4d9eSMateusz Piotrowskithat would be rendered as:
24613bf4d9eSMateusz Piotrowski.Bd -filled -offset indent
24713bf4d9eSMateusz Piotrowski.Va critical_filesystems_ Ns Ar type
24813bf4d9eSMateusz Piotrowski.Ed
24913bf4d9eSMateusz Piotrowski.El
25013bf4d9eSMateusz Piotrowski.Sh SEE ALSO
25113bf4d9eSMateusz Piotrowski.Xr man 1 ,
25213bf4d9eSMateusz Piotrowski.Xr mandoc 1 ,
2536d33315dSMateusz Piotrowski.Xr mdoc 7 ,
2546d33315dSMateusz Piotrowski.Xr style 9
25513bf4d9eSMateusz Piotrowski.Sh HISTORY
25613bf4d9eSMateusz PiotrowskiThis manual page first appeared in
25713bf4d9eSMateusz Piotrowski.Fx 13.0 .
25813bf4d9eSMateusz Piotrowski.Sh AUTHORS
25913bf4d9eSMateusz Piotrowski.An Mateusz Piotrowski Aq Mt 0mp@FreeBSD.org
260