xref: /freebsd/share/man/man5/style.mdoc.5 (revision e7ff917057eaf209c003660f02decb64ccb811da)
1*e7ff9170SAlexander Ziaee.\"-
24d846d26SWarner 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.\"
27*e7ff9170SAlexander Ziaee.Dd April 12, 2024
2813bf4d9eSMateusz Piotrowski.Dt STYLE.MDOC 5
2913bf4d9eSMateusz Piotrowski.Os
3013bf4d9eSMateusz Piotrowski.Sh NAME
3113bf4d9eSMateusz Piotrowski.Nm style.mdoc
3213bf4d9eSMateusz Piotrowski.Nd
3313bf4d9eSMateusz Piotrowski.Fx
3413bf4d9eSMateusz Piotrowski.Xr mdoc 7
35*e7ff9170SAlexander Ziaeemanual page style guide
3613bf4d9eSMateusz Piotrowski.Sh DESCRIPTION
3713bf4d9eSMateusz PiotrowskiThis file specifies the preferred style for manual pages in the
3813bf4d9eSMateusz Piotrowski.Fx
3913bf4d9eSMateusz Piotrowskisource tree.
40e84f6455SMateusz Piotrowski.Ss Code Examples
4113bf4d9eSMateusz Piotrowski.Bl -dash -width ""
4213bf4d9eSMateusz Piotrowski.It
4313bf4d9eSMateusz PiotrowskiUse literal formatting for examples and literal shell commands, e.g.:
4413bf4d9eSMateusz Piotrowski.Bd -literal -offset indent
4513bf4d9eSMateusz PiotrowskiThen run
465e077e08SMateusz Piotrowski\&.Ql make install clean .
4713bf4d9eSMateusz Piotrowski.Ed
4813bf4d9eSMateusz Piotrowski.Pp
4913bf4d9eSMateusz Piotrowskiwhich renders as:
5013bf4d9eSMateusz Piotrowski.Bd -filled -offset indent
5113bf4d9eSMateusz PiotrowskiThen run
525e077e08SMateusz Piotrowski.Ql make install clean .
5313bf4d9eSMateusz Piotrowski.Ed
5413bf4d9eSMateusz Piotrowski.Pp
5513bf4d9eSMateusz PiotrowskiThe incorrect way would be to use macros like
5613bf4d9eSMateusz Piotrowski.Sy \&Nm
5713bf4d9eSMateusz Piotrowskito stylize the command invocation:
5813bf4d9eSMateusz Piotrowski.Bd -literal -offset indent
5913bf4d9eSMateusz PiotrowskiThen run
605e077e08SMateusz Piotrowski\&.Ql Nm make Cm install Cm clean .
6113bf4d9eSMateusz Piotrowski.Ed
6213bf4d9eSMateusz Piotrowski.Pp
6313bf4d9eSMateusz Piotrowskiwhich renders as:
6413bf4d9eSMateusz Piotrowski.Bd -filled -offset indent
6513bf4d9eSMateusz PiotrowskiThen run
665e077e08SMateusz Piotrowski.Ql Nm make Cm install Cm clean .
6713bf4d9eSMateusz Piotrowski.Ed
685e077e08SMateusz Piotrowski.It
695e077e08SMateusz PiotrowskiThe
705e077e08SMateusz Piotrowski.Sy \&Ql
715e077e08SMateusz Piotrowskimacro is the preferred macro for formatting literal inline fragments.
725e077e08SMateusz PiotrowskiHistorically,
735e077e08SMateusz Piotrowski.Sy \&Dq \&Li
745e077e08SMateusz Piotrowskiwas the preferred way before the deprecation of
755e077e08SMateusz Piotrowski.Sy \&Li .
7613bf4d9eSMateusz Piotrowski.El
77e84f6455SMateusz Piotrowski.Ss EXAMPLES Section
78e84f6455SMateusz Piotrowski.Bl -dash -width ""
79e84f6455SMateusz Piotrowski.It
80e84f6455SMateusz PiotrowskiFormat the
81e84f6455SMateusz Piotrowski.Sx EXAMPLES
82e84f6455SMateusz Piotrowskisection in the following way:
83e84f6455SMateusz Piotrowski.Bd -literal -offset indent
84e84f6455SMateusz Piotrowski\&.Bl -tag -width 0n
85*e7ff9170SAlexander Ziaee\&.It Sy Example 1\\&: Doing Something
86e84f6455SMateusz Piotrowski\&.Pp
87e84f6455SMateusz PiotrowskiThe following command does something.
88e84f6455SMateusz Piotrowski\&.Bd -literal -offset 2n
89*e7ff9170SAlexander Ziaee\&.Ic # make -VLEGAL
90e84f6455SMateusz Piotrowski\&.Ed
91*e7ff9170SAlexander Ziaee\&.It Sy Example 2\\&: Doing Something Different
92e84f6455SMateusz Piotrowski\&.Pp
93e84f6455SMateusz PiotrowskiThe following command does something different.
94e84f6455SMateusz Piotrowski\&.Bd -literal -offset 2n
95*e7ff9170SAlexander Ziaee\&.Ic # bectl list
96e84f6455SMateusz Piotrowski\&.Ed
97e84f6455SMateusz Piotrowski\&.Pp
98e84f6455SMateusz PiotrowskiIt is good to know this command.
99e84f6455SMateusz Piotrowski\&.El
100e84f6455SMateusz Piotrowski.Ed
101e84f6455SMateusz Piotrowski.Pp
102e84f6455SMateusz Piotrowskiwhich renders as:
103e84f6455SMateusz Piotrowski.Bl -tag -width 0n
104*e7ff9170SAlexander Ziaee.It Sy Example 1\&: Doing Something
105e84f6455SMateusz Piotrowski.Pp
106e84f6455SMateusz PiotrowskiThe following command does something.
107e84f6455SMateusz Piotrowski.Bd -literal -offset 2n
108*e7ff9170SAlexander Ziaee.Ic # make -VLEGAL
109e84f6455SMateusz Piotrowski.Ed
110*e7ff9170SAlexander Ziaee.It Sy Example 2\&: Doing Something Different
111e84f6455SMateusz Piotrowski.Pp
112e84f6455SMateusz PiotrowskiThe following command does something different.
113e84f6455SMateusz Piotrowski.Bd -literal -offset 2n
114*e7ff9170SAlexander Ziaee.Ic # bectl list
115e84f6455SMateusz Piotrowski.Ed
116e84f6455SMateusz Piotrowski.Pp
117e84f6455SMateusz PiotrowskiIt is good to know this command.
118e84f6455SMateusz Piotrowski.El
119e84f6455SMateusz Piotrowski.El
12079afae3bSMateusz Piotrowski.Ss Lists
12179afae3bSMateusz Piotrowski.Bl -dash -width ""
12279afae3bSMateusz Piotrowski.It
12379afae3bSMateusz PiotrowskiThe
12479afae3bSMateusz Piotrowski.Fl width
12579afae3bSMateusz Piotrowskiargument to the
12679afae3bSMateusz Piotrowski.Sy \&.Bl
12779afae3bSMateusz Piotrowskimacro should match the length of the longest item in the list, e.g.:
12879afae3bSMateusz Piotrowski.Bd -literal -offset indent
12979afae3bSMateusz Piotrowski\&.Bl -tag -width "-a address"
13079afae3bSMateusz Piotrowski\&.It Fl a Ar address
13179afae3bSMateusz PiotrowskiSet the address.
13279afae3bSMateusz Piotrowski\&.It Fl v
13379afae3bSMateusz PiotrowskiPrint the version.
13479afae3bSMateusz Piotrowski\&.El
13579afae3bSMateusz Piotrowski.Ed
13679afae3bSMateusz Piotrowski.Pp
13779afae3bSMateusz PiotrowskiIn case the longest item is too long and hurts readability,
13879afae3bSMateusz Piotrowskithe recommendation is to set
13979afae3bSMateusz Piotrowskithe
14079afae3bSMateusz Piotrowski.Fl width
14179afae3bSMateusz Piotrowskiargument
14279afae3bSMateusz Piotrowskito
14379afae3bSMateusz Piotrowski.Ql indent ,
14479afae3bSMateusz Piotrowskie.g.:
14579afae3bSMateusz Piotrowski.Bd -literal -offset indent
14679afae3bSMateusz Piotrowski\&.Bl -tag -width "indent"
14779afae3bSMateusz Piotrowski\&.It Cm build
14879afae3bSMateusz PiotrowskiBuild the port.
14979afae3bSMateusz Piotrowski\&.It Cm install
15079afae3bSMateusz PiotrowskiInstall the port.
15179afae3bSMateusz Piotrowski\&.It Fl install-missing-packages
15279afae3bSMateusz PiotrowskiInstall the missing packages.
15379afae3bSMateusz Piotrowski\&.El
15479afae3bSMateusz Piotrowski.Ed
15579afae3bSMateusz Piotrowski.El
156e84f6455SMateusz Piotrowski.Ss Synopsis Formatting
15713bf4d9eSMateusz Piotrowski.Bl -dash -width ""
15813bf4d9eSMateusz Piotrowski.It
15913bf4d9eSMateusz PiotrowskiDo not put whitespace between alternative parameters separated with a pipe
16013bf4d9eSMateusz Piotrowski.Pq Dq | ,
16113bf4d9eSMateusz Piotrowskie.g.:
16213bf4d9eSMateusz Piotrowski.Bd -literal -offset indent
16313bf4d9eSMateusz Piotrowski\&.Cm compression Cm on Ns | Ns Cm off
16413bf4d9eSMateusz Piotrowski\&.Cm install Fl -all Ns | Ns Ar portname Ar ...
16513bf4d9eSMateusz Piotrowski.Ed
16613bf4d9eSMateusz Piotrowski.Pp
16713bf4d9eSMateusz Piotrowskiwhich in the SYNOPSIS section is rendered as:
16813bf4d9eSMateusz Piotrowski.Bd -unfilled -offset indent
16913bf4d9eSMateusz Piotrowski.Cm compression Cm on Ns | Ns Cm off
17013bf4d9eSMateusz Piotrowski.Cm install Fl -all Ns | Ns Ar portname Ar ...
17113bf4d9eSMateusz Piotrowski.Ed
17213bf4d9eSMateusz Piotrowski.It
17313bf4d9eSMateusz PiotrowskiUse
17413bf4d9eSMateusz Piotrowski.Sy \&Cm
17513bf4d9eSMateusz Piotrowskito stylize characters that are command modifiers
17613bf4d9eSMateusz Piotrowski.Po e.g.,
17713bf4d9eSMateusz Piotrowski.Dq \&, ,
17813bf4d9eSMateusz Piotrowski.Dq @
17913bf4d9eSMateusz Piotrowskior
18013bf4d9eSMateusz Piotrowski.Dq "="
18113bf4d9eSMateusz Piotrowski.Pc .
18213bf4d9eSMateusz PiotrowskiFor example:
18313bf4d9eSMateusz Piotrowski.Bd -literal -offset indent
18413bf4d9eSMateusz Piotrowski\&.Sm off
18513bf4d9eSMateusz Piotrowski\&.Fl -meet Cm = Ar who Oo Cm \&, Ar who " " Ar "..." Oc Cm @ Ar where
18613bf4d9eSMateusz Piotrowski\&.Sm on
18713bf4d9eSMateusz Piotrowski.Ed
18813bf4d9eSMateusz Piotrowski.Pp
18913bf4d9eSMateusz Piotrowskiwhich renders as:
19013bf4d9eSMateusz Piotrowski.Bd -filled -offset indent
19113bf4d9eSMateusz Piotrowski.Sm off
19213bf4d9eSMateusz Piotrowski.Fl -meet Cm = Ar who Oo Cm \&, Ar who " " Ar "..." Oc Cm @ Ar where
19313bf4d9eSMateusz Piotrowski.Sm on
19413bf4d9eSMateusz Piotrowski.Ed
19513bf4d9eSMateusz Piotrowski.Pp
19613bf4d9eSMateusz Piotrowskiinstead of:
19713bf4d9eSMateusz Piotrowski.Bd -literal -offset indent
19813bf4d9eSMateusz Piotrowski\&.Sm off
19913bf4d9eSMateusz Piotrowski\&.Fl -meet No = Ar who Oo , Ar who " " Ar "..." Oc @ Ar where
20013bf4d9eSMateusz Piotrowski\&.Sm on
20113bf4d9eSMateusz Piotrowski.Ed
20213bf4d9eSMateusz Piotrowski.Pp
20313bf4d9eSMateusz Piotrowskiwhich would render as:
20413bf4d9eSMateusz Piotrowski.Bd -filled -offset indent
20513bf4d9eSMateusz Piotrowski.Sm off
20613bf4d9eSMateusz Piotrowski.Fl -meet No = Ar who Oo , Ar who " " Ar "..." Oc @ Ar where
20713bf4d9eSMateusz Piotrowski.Sm on
20813bf4d9eSMateusz Piotrowski.Ed
20913bf4d9eSMateusz Piotrowski.Pp
21013bf4d9eSMateusz PiotrowskiIt is important to realize that in the correct example,
21113bf4d9eSMateusz Piotrowski.Dq \&, ,
21213bf4d9eSMateusz Piotrowski.Dq @
21313bf4d9eSMateusz Piotrowskiand
21413bf4d9eSMateusz Piotrowski.Dq =
21513bf4d9eSMateusz Piotrowskiare stylized with
21613bf4d9eSMateusz Piotrowski.Sy \&Cm .
21713bf4d9eSMateusz PiotrowskiAt the same time, the square brackets
21813bf4d9eSMateusz Piotrowski.Pq Dq "[]"
21913bf4d9eSMateusz Piotrowskiare not stylized as they do not belong to the syntax of the
22013bf4d9eSMateusz Piotrowski.Fl -meet
22113bf4d9eSMateusz Piotrowskiflag.
22213bf4d9eSMateusz Piotrowski.El
22313bf4d9eSMateusz Piotrowski.Ss Quoting
22413bf4d9eSMateusz Piotrowski.Bl -dash -width ""
22513bf4d9eSMateusz Piotrowski.It
22613bf4d9eSMateusz PiotrowskiUse the
22713bf4d9eSMateusz Piotrowski.Sy \&Dq
22813bf4d9eSMateusz Piotrowski.Pq Do Dc
22913bf4d9eSMateusz Piotrowskimacro
23013bf4d9eSMateusz Piotrowskifor quoting.
23113bf4d9eSMateusz PiotrowskiUse the
23213bf4d9eSMateusz Piotrowski.Sy \&Sq
23313bf4d9eSMateusz Piotrowski.Pq So Sc
23413bf4d9eSMateusz Piotrowskimacro for quoting inside quotes.
23513bf4d9eSMateusz PiotrowskiThe use of the
23613bf4d9eSMateusz Piotrowski.Sy \&Qq
23713bf4d9eSMateusz Piotrowski.Pq Qo Qc
23813bf4d9eSMateusz Piotrowskimacro is usually not necessary.
23913bf4d9eSMateusz Piotrowski.El
24013bf4d9eSMateusz Piotrowski.Ss Variables
24113bf4d9eSMateusz Piotrowski.Bl -dash -width ""
24213bf4d9eSMateusz Piotrowski.It
24313bf4d9eSMateusz PiotrowskiUse
24413bf4d9eSMateusz Piotrowski.Sy \&Va
2456e33d37fSMateusz Piotrowskiinstead of
24613bf4d9eSMateusz Piotrowski.Sy \&Dv
24713bf4d9eSMateusz Piotrowskifor
24813bf4d9eSMateusz Piotrowski.Xr sysctl 8
24913bf4d9eSMateusz Piotrowskivariables like
25013bf4d9eSMateusz Piotrowski.Va kdb.enter.panic .
25113bf4d9eSMateusz Piotrowski.It
25213bf4d9eSMateusz PiotrowskiUse the angle brackets
25313bf4d9eSMateusz Piotrowski.Sy \&Aq
25413bf4d9eSMateusz Piotrowski.Pq Dq "<>"
25513bf4d9eSMateusz Piotrowskimacro
25613bf4d9eSMateusz Piotrowskifor arguments
25713bf4d9eSMateusz Piotrowski.Pq Sy \&Ar
25813bf4d9eSMateusz Piotrowskiwhen they are mixed with similarly stylized macros like
25913bf4d9eSMateusz Piotrowski.Sy \&Pa
26013bf4d9eSMateusz Piotrowskior
26113bf4d9eSMateusz Piotrowski.Sy \&Va ,
26213bf4d9eSMateusz Piotrowskie.g.:
26313bf4d9eSMateusz Piotrowski.Bd -literal -offset indent
26413bf4d9eSMateusz Piotrowski\&.Va critical_filesystems_ Ns Aq Ar type
26513bf4d9eSMateusz Piotrowski.Ed
26613bf4d9eSMateusz Piotrowski.Pp
26713bf4d9eSMateusz Piotrowskiwhich renders as:
26813bf4d9eSMateusz Piotrowski.Bd -filled -offset indent
26913bf4d9eSMateusz Piotrowski.Va critical_filesystems_ Ns Aq Ar type
27013bf4d9eSMateusz Piotrowski.Ed
27113bf4d9eSMateusz Piotrowski.Pp
27213bf4d9eSMateusz Piotrowskiinstead of:
27313bf4d9eSMateusz Piotrowski.Bd -literal -offset indent
27413bf4d9eSMateusz Piotrowski\&.Va critical_filesystems_ Ns Ar type
27513bf4d9eSMateusz Piotrowski.Ed
27613bf4d9eSMateusz Piotrowski.Pp
27713bf4d9eSMateusz Piotrowskithat would be rendered as:
27813bf4d9eSMateusz Piotrowski.Bd -filled -offset indent
27913bf4d9eSMateusz Piotrowski.Va critical_filesystems_ Ns Ar type
28013bf4d9eSMateusz Piotrowski.Ed
28113bf4d9eSMateusz Piotrowski.El
28213bf4d9eSMateusz Piotrowski.Sh SEE ALSO
28313bf4d9eSMateusz Piotrowski.Xr man 1 ,
28413bf4d9eSMateusz Piotrowski.Xr mandoc 1 ,
2856d33315dSMateusz Piotrowski.Xr mdoc 7 ,
286*e7ff9170SAlexander Ziaee.Xr roff 7 ,
2876d33315dSMateusz Piotrowski.Xr style 9
28813bf4d9eSMateusz Piotrowski.Sh HISTORY
28913bf4d9eSMateusz PiotrowskiThis manual page first appeared in
29013bf4d9eSMateusz Piotrowski.Fx 13.0 .
29113bf4d9eSMateusz Piotrowski.Sh AUTHORS
29213bf4d9eSMateusz Piotrowski.An Mateusz Piotrowski Aq Mt 0mp@FreeBSD.org
293