-
SPDX-License-Identifier: BSD-2-Clause

Copyright (c) 2018-2022 Mateusz Piotrowski <0mp@FreeBSD.org>

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.

.Dd April 12, 2024 .Dt STYLE.MDOC 5 .Os .Sh NAME .Nm style.mdoc .Nd .Fx .Xr mdoc 7 manual page style guide .Sh DESCRIPTION This file specifies the preferred style for manual pages in the .Fx source tree. .Ss Code Examples l -dash -width "" t Use literal formatting for examples and literal shell commands, e.g.: d -literal -offset indent Then run .Ql make install clean . .Ed

p which renders as: d -filled -offset indent Then run .Ql make install clean . .Ed

p The incorrect way would be to use macros like .Sy Nm to stylize the command invocation: d -literal -offset indent Then run .Ql Nm make Cm install Cm clean . .Ed

p which renders as: d -filled -offset indent Then run .Ql Nm make Cm install Cm clean . .Ed t The .Sy Ql macro is the preferred macro for formatting literal inline fragments. Historically, .Sy Dq Li was the preferred way before the deprecation of .Sy Li . .El .Ss EXAMPLES Section l -dash -width "" t Format the .Sx EXAMPLES section in the following way: d -literal -offset indent .Bl -tag -width 0n .It Sy Example 1\: Doing Something .Pp The following command does something. .Bd -literal -offset 2n .Ic # make -VLEGAL .Ed .It Sy Example 2\: Doing Something Different .Pp The following command does something different. .Bd -literal -offset 2n .Ic # bectl list .Ed .Pp It is good to know this command. .El .Ed

p which renders as: l -tag -width 0n t Sy Example 1: Doing Something

p The following command does something. d -literal -offset 2n c # make -VLEGAL .Ed t Sy Example 2: Doing Something Different

p The following command does something different. d -literal -offset 2n c # bectl list .Ed

p It is good to know this command. .El .El .Ss Lists l -dash -width "" t The .Fl width argument to the .Sy .Bl macro should match the length of the longest item in the list, e.g.: d -literal -offset indent .Bl -tag -width "-a address" .It Fl a Ar address Set the address. .It Fl v Print the version. .El .Ed

p In case the longest item is too long and hurts readability, the recommendation is to set the .Fl width argument to .Ql indent , e.g.: d -literal -offset indent .Bl -tag -width "indent" .It Cm build Build the port. .It Cm install Install the port. .It Fl install-missing-packages Install the missing packages. .El .Ed .El .Ss Synopsis Formatting l -dash -width "" t Do not put whitespace between alternative parameters separated with a pipe

q Dq | , e.g.: d -literal -offset indent .Cm compression Cm on Ns | Ns Cm off .Cm install Fl -all Ns | Ns Ar portname Ar ... .Ed

p which in the SYNOPSIS section is rendered as: d -unfilled -offset indent .Cm compression Cm on Ns | Ns Cm off .Cm install Fl -all Ns | Ns Ar portname Ar ... .Ed t Use .Sy Cm to stylize characters that are command modifiers

o e.g., .Dq , , .Dq @ or .Dq "="

c . For example: d -literal -offset indent .Sm off .Fl -meet Cm = Ar who Oo Cm , Ar who " " Ar "..." Oc Cm @ Ar where .Sm on .Ed

p which renders as: d -filled -offset indent .Sm off .Fl -meet Cm = Ar who Oo Cm , Ar who " " Ar "..." Oc Cm @ Ar where .Sm on .Ed

p instead of: d -literal -offset indent .Sm off .Fl -meet No = Ar who Oo , Ar who " " Ar "..." Oc @ Ar where .Sm on .Ed

p which would render as: d -filled -offset indent .Sm off .Fl -meet No = Ar who Oo , Ar who " " Ar "..." Oc @ Ar where .Sm on .Ed

p It is important to realize that in the correct example, .Dq , , .Dq @ and .Dq = are stylized with .Sy Cm . At the same time, the square brackets

q Dq "[]" are not stylized as they do not belong to the syntax of the .Fl -meet flag. .El .Ss Quoting l -dash -width "" t Use the .Sy Dq

q Do Dc macro for quoting. Use the .Sy Sq

q So Sc macro for quoting inside quotes. The use of the .Sy Qq

q Qo Qc macro is usually not necessary. .El .Ss Variables l -dash -width "" t Use .Sy Va instead of .Sy Dv for .Xr sysctl 8 variables like .Va kdb.enter.panic . t Use the angle brackets .Sy Aq

q Dq "<>" macro for arguments

q Sy Ar when they are mixed with similarly stylized macros like .Sy Pa or .Sy Va , e.g.: d -literal -offset indent .Va critical_filesystems_ Ns Aq Ar type .Ed

p which renders as: d -filled -offset indent .Va critical_filesystems_ Ns Aq Ar type .Ed

p instead of: d -literal -offset indent .Va critical_filesystems_ Ns Ar type .Ed

p that would be rendered as: d -filled -offset indent .Va critical_filesystems_ Ns Ar type .Ed .El .Sh SEE ALSO .Xr man 1 , .Xr mandoc 1 , .Xr mdoc 7 , .Xr roff 7 , .Xr style 9 .Sh HISTORY This manual page first appeared in .Fx 13.0 . .Sh AUTHORS .An Mateusz Piotrowski Aq Mt 0mp@FreeBSD.org