xref: /freebsd/share/man/man5/style.mdoc.5 (revision 4d846d260e2b9a3d4d0a701462568268cbfe7a5b)
113bf4d9eSMateusz Piotrowski.\"
2*4d846d26SWarner Losh.\" SPDX-License-Identifier: BSD-2-Clause
313bf4d9eSMateusz Piotrowski.\"
479afae3bSMateusz Piotrowski.\" Copyright (c) 2018-2022 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.\"
2979afae3bSMateusz Piotrowski.Dd January 29, 2022
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
485e077e08SMateusz Piotrowski\&.Ql make install clean .
4913bf4d9eSMateusz Piotrowski.Ed
5013bf4d9eSMateusz Piotrowski.Pp
5113bf4d9eSMateusz Piotrowskiwhich renders as:
5213bf4d9eSMateusz Piotrowski.Bd -filled -offset indent
5313bf4d9eSMateusz PiotrowskiThen run
545e077e08SMateusz 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
625e077e08SMateusz 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
685e077e08SMateusz Piotrowski.Ql Nm make Cm install Cm clean .
6913bf4d9eSMateusz Piotrowski.Ed
705e077e08SMateusz Piotrowski.It
715e077e08SMateusz PiotrowskiThe
725e077e08SMateusz Piotrowski.Sy \&Ql
735e077e08SMateusz Piotrowskimacro is the preferred macro for formatting literal inline fragments.
745e077e08SMateusz PiotrowskiHistorically,
755e077e08SMateusz Piotrowski.Sy \&Dq \&Li
765e077e08SMateusz Piotrowskiwas the preferred way before the deprecation of
775e077e08SMateusz 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
12479afae3bSMateusz Piotrowski.Ss Lists
12579afae3bSMateusz Piotrowski.Bl -dash -width ""
12679afae3bSMateusz Piotrowski.It
12779afae3bSMateusz PiotrowskiThe
12879afae3bSMateusz Piotrowski.Fl width
12979afae3bSMateusz Piotrowskiargument to the
13079afae3bSMateusz Piotrowski.Sy \&.Bl
13179afae3bSMateusz Piotrowskimacro should match the length of the longest item in the list, e.g.:
13279afae3bSMateusz Piotrowski.Bd -literal -offset indent
13379afae3bSMateusz Piotrowski\&.Bl -tag -width "-a address"
13479afae3bSMateusz Piotrowski\&.It Fl a Ar address
13579afae3bSMateusz PiotrowskiSet the address.
13679afae3bSMateusz Piotrowski\&.It Fl v
13779afae3bSMateusz PiotrowskiPrint the version.
13879afae3bSMateusz Piotrowski\&.El
13979afae3bSMateusz Piotrowski.Ed
14079afae3bSMateusz Piotrowski.Pp
14179afae3bSMateusz PiotrowskiIn case the longest item is too long and hurts readability,
14279afae3bSMateusz Piotrowskithe recommendation is to set
14379afae3bSMateusz Piotrowskithe
14479afae3bSMateusz Piotrowski.Fl width
14579afae3bSMateusz Piotrowskiargument
14679afae3bSMateusz Piotrowskito
14779afae3bSMateusz Piotrowski.Ql indent ,
14879afae3bSMateusz Piotrowskie.g.:
14979afae3bSMateusz Piotrowski.Bd -literal -offset indent
15079afae3bSMateusz Piotrowski\&.Bl -tag -width "indent"
15179afae3bSMateusz Piotrowski\&.It Cm build
15279afae3bSMateusz PiotrowskiBuild the port.
15379afae3bSMateusz Piotrowski\&.It Cm install
15479afae3bSMateusz PiotrowskiInstall the port.
15579afae3bSMateusz Piotrowski\&.It Fl install-missing-packages
15679afae3bSMateusz PiotrowskiInstall the missing packages.
15779afae3bSMateusz Piotrowski\&.El
15879afae3bSMateusz Piotrowski.Ed
15979afae3bSMateusz Piotrowski.El
160e84f6455SMateusz Piotrowski.Ss Synopsis Formatting
16113bf4d9eSMateusz Piotrowski.Bl -dash -width ""
16213bf4d9eSMateusz Piotrowski.It
16313bf4d9eSMateusz PiotrowskiDo not put whitespace between alternative parameters separated with a pipe
16413bf4d9eSMateusz Piotrowski.Pq Dq | ,
16513bf4d9eSMateusz Piotrowskie.g.:
16613bf4d9eSMateusz Piotrowski.Bd -literal -offset indent
16713bf4d9eSMateusz Piotrowski\&.Cm compression Cm on Ns | Ns Cm off
16813bf4d9eSMateusz Piotrowski\&.Cm install Fl -all Ns | Ns Ar portname Ar ...
16913bf4d9eSMateusz Piotrowski.Ed
17013bf4d9eSMateusz Piotrowski.Pp
17113bf4d9eSMateusz Piotrowskiwhich in the SYNOPSIS section is rendered as:
17213bf4d9eSMateusz Piotrowski.Bd -unfilled -offset indent
17313bf4d9eSMateusz Piotrowski.Cm compression Cm on Ns | Ns Cm off
17413bf4d9eSMateusz Piotrowski.Cm install Fl -all Ns | Ns Ar portname Ar ...
17513bf4d9eSMateusz Piotrowski.Ed
17613bf4d9eSMateusz Piotrowski.It
17713bf4d9eSMateusz PiotrowskiUse
17813bf4d9eSMateusz Piotrowski.Sy \&Cm
17913bf4d9eSMateusz Piotrowskito stylize characters that are command modifiers
18013bf4d9eSMateusz Piotrowski.Po e.g.,
18113bf4d9eSMateusz Piotrowski.Dq \&, ,
18213bf4d9eSMateusz Piotrowski.Dq @
18313bf4d9eSMateusz Piotrowskior
18413bf4d9eSMateusz Piotrowski.Dq "="
18513bf4d9eSMateusz Piotrowski.Pc .
18613bf4d9eSMateusz PiotrowskiFor example:
18713bf4d9eSMateusz Piotrowski.Bd -literal -offset indent
18813bf4d9eSMateusz Piotrowski\&.Sm off
18913bf4d9eSMateusz Piotrowski\&.Fl -meet Cm = Ar who Oo Cm \&, Ar who " " Ar "..." Oc Cm @ Ar where
19013bf4d9eSMateusz Piotrowski\&.Sm on
19113bf4d9eSMateusz Piotrowski.Ed
19213bf4d9eSMateusz Piotrowski.Pp
19313bf4d9eSMateusz Piotrowskiwhich renders as:
19413bf4d9eSMateusz Piotrowski.Bd -filled -offset indent
19513bf4d9eSMateusz Piotrowski.Sm off
19613bf4d9eSMateusz Piotrowski.Fl -meet Cm = Ar who Oo Cm \&, Ar who " " Ar "..." Oc Cm @ Ar where
19713bf4d9eSMateusz Piotrowski.Sm on
19813bf4d9eSMateusz Piotrowski.Ed
19913bf4d9eSMateusz Piotrowski.Pp
20013bf4d9eSMateusz Piotrowskiinstead of:
20113bf4d9eSMateusz Piotrowski.Bd -literal -offset indent
20213bf4d9eSMateusz Piotrowski\&.Sm off
20313bf4d9eSMateusz Piotrowski\&.Fl -meet No = Ar who Oo , Ar who " " Ar "..." Oc @ Ar where
20413bf4d9eSMateusz Piotrowski\&.Sm on
20513bf4d9eSMateusz Piotrowski.Ed
20613bf4d9eSMateusz Piotrowski.Pp
20713bf4d9eSMateusz Piotrowskiwhich would render as:
20813bf4d9eSMateusz Piotrowski.Bd -filled -offset indent
20913bf4d9eSMateusz Piotrowski.Sm off
21013bf4d9eSMateusz Piotrowski.Fl -meet No = Ar who Oo , Ar who " " Ar "..." Oc @ Ar where
21113bf4d9eSMateusz Piotrowski.Sm on
21213bf4d9eSMateusz Piotrowski.Ed
21313bf4d9eSMateusz Piotrowski.Pp
21413bf4d9eSMateusz PiotrowskiIt is important to realize that in the correct example,
21513bf4d9eSMateusz Piotrowski.Dq \&, ,
21613bf4d9eSMateusz Piotrowski.Dq @
21713bf4d9eSMateusz Piotrowskiand
21813bf4d9eSMateusz Piotrowski.Dq =
21913bf4d9eSMateusz Piotrowskiare stylized with
22013bf4d9eSMateusz Piotrowski.Sy \&Cm .
22113bf4d9eSMateusz PiotrowskiAt the same time, the square brackets
22213bf4d9eSMateusz Piotrowski.Pq Dq "[]"
22313bf4d9eSMateusz Piotrowskiare not stylized as they do not belong to the syntax of the
22413bf4d9eSMateusz Piotrowski.Fl -meet
22513bf4d9eSMateusz Piotrowskiflag.
22613bf4d9eSMateusz Piotrowski.El
22713bf4d9eSMateusz Piotrowski.Ss Quoting
22813bf4d9eSMateusz Piotrowski.Bl -dash -width ""
22913bf4d9eSMateusz Piotrowski.It
23013bf4d9eSMateusz PiotrowskiUse the
23113bf4d9eSMateusz Piotrowski.Sy \&Dq
23213bf4d9eSMateusz Piotrowski.Pq Do Dc
23313bf4d9eSMateusz Piotrowskimacro
23413bf4d9eSMateusz Piotrowskifor quoting.
23513bf4d9eSMateusz PiotrowskiUse the
23613bf4d9eSMateusz Piotrowski.Sy \&Sq
23713bf4d9eSMateusz Piotrowski.Pq So Sc
23813bf4d9eSMateusz Piotrowskimacro for quoting inside quotes.
23913bf4d9eSMateusz PiotrowskiThe use of the
24013bf4d9eSMateusz Piotrowski.Sy \&Qq
24113bf4d9eSMateusz Piotrowski.Pq Qo Qc
24213bf4d9eSMateusz Piotrowskimacro is usually not necessary.
24313bf4d9eSMateusz Piotrowski.El
24413bf4d9eSMateusz Piotrowski.Ss Variables
24513bf4d9eSMateusz Piotrowski.Bl -dash -width ""
24613bf4d9eSMateusz Piotrowski.It
24713bf4d9eSMateusz PiotrowskiUse
24813bf4d9eSMateusz Piotrowski.Sy \&Va
2496e33d37fSMateusz Piotrowskiinstead of
25013bf4d9eSMateusz Piotrowski.Sy \&Dv
25113bf4d9eSMateusz Piotrowskifor
25213bf4d9eSMateusz Piotrowski.Xr sysctl 8
25313bf4d9eSMateusz Piotrowskivariables like
25413bf4d9eSMateusz Piotrowski.Va kdb.enter.panic .
25513bf4d9eSMateusz Piotrowski.It
25613bf4d9eSMateusz PiotrowskiUse the angle brackets
25713bf4d9eSMateusz Piotrowski.Sy \&Aq
25813bf4d9eSMateusz Piotrowski.Pq Dq "<>"
25913bf4d9eSMateusz Piotrowskimacro
26013bf4d9eSMateusz Piotrowskifor arguments
26113bf4d9eSMateusz Piotrowski.Pq Sy \&Ar
26213bf4d9eSMateusz Piotrowskiwhen they are mixed with similarly stylized macros like
26313bf4d9eSMateusz Piotrowski.Sy \&Pa
26413bf4d9eSMateusz Piotrowskior
26513bf4d9eSMateusz Piotrowski.Sy \&Va ,
26613bf4d9eSMateusz Piotrowskie.g.:
26713bf4d9eSMateusz Piotrowski.Bd -literal -offset indent
26813bf4d9eSMateusz Piotrowski\&.Va critical_filesystems_ Ns Aq Ar type
26913bf4d9eSMateusz Piotrowski.Ed
27013bf4d9eSMateusz Piotrowski.Pp
27113bf4d9eSMateusz Piotrowskiwhich renders as:
27213bf4d9eSMateusz Piotrowski.Bd -filled -offset indent
27313bf4d9eSMateusz Piotrowski.Va critical_filesystems_ Ns Aq Ar type
27413bf4d9eSMateusz Piotrowski.Ed
27513bf4d9eSMateusz Piotrowski.Pp
27613bf4d9eSMateusz Piotrowskiinstead of:
27713bf4d9eSMateusz Piotrowski.Bd -literal -offset indent
27813bf4d9eSMateusz Piotrowski\&.Va critical_filesystems_ Ns Ar type
27913bf4d9eSMateusz Piotrowski.Ed
28013bf4d9eSMateusz Piotrowski.Pp
28113bf4d9eSMateusz Piotrowskithat would be rendered as:
28213bf4d9eSMateusz Piotrowski.Bd -filled -offset indent
28313bf4d9eSMateusz Piotrowski.Va critical_filesystems_ Ns Ar type
28413bf4d9eSMateusz Piotrowski.Ed
28513bf4d9eSMateusz Piotrowski.El
28613bf4d9eSMateusz Piotrowski.Sh SEE ALSO
28713bf4d9eSMateusz Piotrowski.Xr man 1 ,
28813bf4d9eSMateusz Piotrowski.Xr mandoc 1 ,
2896d33315dSMateusz Piotrowski.Xr mdoc 7 ,
2906d33315dSMateusz Piotrowski.Xr style 9
29113bf4d9eSMateusz Piotrowski.Sh HISTORY
29213bf4d9eSMateusz PiotrowskiThis manual page first appeared in
29313bf4d9eSMateusz Piotrowski.Fx 13.0 .
29413bf4d9eSMateusz Piotrowski.Sh AUTHORS
29513bf4d9eSMateusz Piotrowski.An Mateusz Piotrowski Aq Mt 0mp@FreeBSD.org
296