STYLE.MDOC(5)
π so you wanna write a FreeBSD man page π
okay bestie, welcome to style.mdoc(5) β the FreeBSD manual page style guide, straight out of the File Formats Manual section. this is the whole vibe check for how man pages in the FreeBSD source tree are supposed to look β¨
β¨ DESCRIPTION β¨
this file spells out the preferred style for manual pages in the FreeBSD source tree. that's it, that's the assignment π«Ά
π Code Examples π
- use literal formatting for examples and literal shell commands, like this:
Then run
.Ql make install clean .
which renders as:
Then run βmake install cleanβ.
the incorrect way would be reaching for macros like Nm to stylize the command invocation:
Then run
.Ql Nm make Cm install Cm clean .
which renders as:
Then run βmake install cleanβ.
(yes bestie, same render, different crime β don't do the macro one π)
π§ Copyright Header π§
go refer to style(9). that's it. that's the whole note π₯
πΈ HARDWARE Section πΈ
driver manuals in section four should have a βHARDWAREβ section describing hardware known to work with the driver. this section is drawn verbatim into the Release Hardware Notes, so there's several things to note π
- the introductory sentence should be in the form:
The
.Nm
driver supports the following $device_class:
followed by the list of supported hardware.
this defines what driver the subsection is referring to, and lets the reader search through the Hardware Notes not only for the device models they have, but also for the device type they're looking to acquire. iykyk π
- the supported hardware should be listed as a bullet list, or β if complexity requires it β a column list. these two list types create very neat subsections with clean starting and stopping points. iconic behaviour, honestly β
π¦ EXAMPLES Section π¦
- format the βEXAMPLESβ section in the following way:
.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
which renders as:
Example 1: Doing Something
The following command does something.
# make -VLEGAL
Example 2: Doing Something Different
The following command does something different.
# bectl list
It is good to know this command.
look at that structure. immaculate. no notes π
π Lists π
- the
-widthargument to the.Blmacro should match the length of the longest rendered item in the list, e.g.:
.Bl -tag -width "-a address"
.It Fl a Ar address
Set the address.
.It Fl v
Print the version.
.El
in case the longest item is too long and hurts readability, the recommendation is to set the -width argument to βindentβ, e.g.:
.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
matching widths = main character energy. unmatched widths = chaos π
π Quoting π
- use the
Dq(ββ) macro for quoting. use theSq(ββ) macro for quoting inside quotes. the use of theQq("") macro is usually not necessary. that's the whole hierarchy, bestie π
π Variables π
- use
Vainstead ofDvforsysctl(8)variables likekdb.enter.panic. - use the angle brackets
Aq(ββ¨β©β) macro for arguments (Ar) when they're mixed with similarly stylized macros likePaorVa, e.g.:
.Va critical_filesystems_ Ns Aq Ar type
which renders as:
critical_filesystems_β¨typeβ©
instead of:
.Va critical_filesystems_ Ns Ar type
that would be rendered as:
critical_filesystems_type
see the difference? the brackets are eating, and the plain one is lowkey giving nothing. use the Aq β¨
π FILES π
/usr/share/examples/mdoc/β Examples for writing manual pages. go peek, it's free real estate π
π SEE ALSO π
man(1), mandoc(1), mdoc(7), roff(7), style(9)
π°οΈ HISTORY π°οΈ
this manual page first appeared in FreeBSD 13.0. a modern icon, fr fr π
π«Ά AUTHORS π«Ά
Mateusz Piotrowski <0mp@FreeBSD.org> β thank you for your service, king π
and that's the whole style guide, bestie β go forth and format π
this lil rendering of the page came from the Debian build, dated February 16, 2025 β so if u see this in the wild, that's who's serving it to u π¦
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π the page's license: BSD-2-Clause
- Copyright (c) 2018-2025 Mateusz Piotrowski <0mp@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms