1 .Dd $Mdocdate: March 22 2009 $
6 .Nm Writing UNIX Documentation
7 .Nd a guide to writing UNIX manuals
10 .Em A utility without good documentation is of no utility at all .
13 A system component's documentation describes the utility of that
14 component, whether it's a device driver, an executable or, most
15 importantly, a game. Although there are plenty of documents available
18 documents, or where to find them, few focus on composition.
21 This document serves as a tutorial to writing
25 If you add something to your operating system, whether it's a new file
26 format or directory structure or device driver, it needs documentation.
29 Classify your system component. In
31 each component has a manual section , which categorises the component's
32 function. The section of a manual is usually listed in parenthesis next
33 to the component name, such as
35 section 1. You can query a manual explicitly by its section:
36 .Bd -literal -offset XXXX
41 The following table lists classifications and the applicable manual
44 .Bl -tag -width "XXXXXXXXXXXX" -offset indent -compact
52 programming libraries (C, Perl, Fortran)
54 file and wire protocol formats
58 tutorials, documents and papers
60 administrator utilities
65 Some examples in regular name/section form:
68 .Bl -tag -width "File-formatX" -offset indent -compact
72 DEC/Intel 10/100 Ethernet device
74 modify user login information
80 open or create a file for reading or writing
82 whitespace character test
84 convert POD data to formatted roff
88 format of the password file
90 symbolic link handling
94 Prepare your composition environment by copying over the manual template
96 .Pa /usr/share/misc/mdoc.template .
98 start afresh or by copying another manual unless you know exactly what
102 Your component will need a name by which to query its contents via
104 Keep it simple. You may want to look for other manuals by that same
105 name before committing:
109 Conventionally, manual files are named
122 There exist other documentation-specific languages, such as the
130 newer languages such as DocBook, texinfo or schema-driven XML; or even
131 ad-hoc conventions such as README files.
132 .Em Stay away from these methods!
133 Historical formats fail to capture a manual's semantic content, instead
134 only modelling its style. Newer methods requires special,
135 system-specific tools and may change or become obsolete over the
136 life-time of your component.
138 There are two canonical references for writing mdoc manuals:
141 .Bl -tag -width XXXXXXXXXXXXXXXX -offset indent -compact
143 formal language reference
144 .It Xr mdoc.samples 7
148 Open the template you've copied into
152 .Ss Development Tools
153 While writing, make sure that your manual is correctly structured:
155 .Dl % mandoc \-Tlint \-Wall name.1
157 You may spell-check your work as follows:
159 .Dl % deroff name.1 | spell
160 .Dl % ispell \-n name.1
164 or, if not available,
166 to version-control your work. If you wish the last check-in to effect
167 your document's date, use the following RCS tag for the date macro:
169 .Dl \&.Dd $Mdocdate: March 22 2009 $
172 mdoc documents may be paged to your terminal with traditional
176 or with newer, more powerful tools such as
179 .Bd -literal -offset indent
180 % nroff \-mandoc name.1 | less
181 % groff \-Tascii \-mandoc name.1 | less
182 % mandoc name.1 | less
185 Other output formats are also supported:
187 .Bd -literal -offset indent
188 % groff \-Tps \-mandoc name.1 | less
189 % mandoc \-Thtml name.1 | less
193 Consider adding your mdoc documents to
195 Makefiles in order to automatically check your input and generate
197 .Bd -literal -offset indent
198 \&.SUFFIXES: .html .txt .1 .in
201 mandoc -Wall,error -Tlint $<
208 mandoc -Tascii $< | col -b >$@
216 files are indispensable in guiding composition. In this section, we
219 manual best practices:
224 Use clear, concise language. Favour simplicity.
226 Write your manual in non-idiomatic English. Don't worry about
227 Commonwealth or American spellings \(em just correct ones.
229 Spell-check your manual, keeping in mind short-letter terms (
234 If you absolutely must use special characters (diacritics, mathematical
235 symbols and so on), use the escapes dictated in
240 Other components may be referenced with the
244 macros. Make sure that these exist. If you intend to distribute your
247 references are valid across systems (within reason). If you cross-link with
249 make sure that the section reference exists.
252 Cite your work. If your system references standards documents or other
253 publications, please use the
258 Let the front-ends worry about formatting for you, but if you must think
259 about formatting (at times necessary, especially for tagged and columnar
260 lists), assume that your output device is a fixed-width terminal window:
261 .Bd -literal -offset indent
262 \&.Bl \-tag \-width "-o outfile"
263 \&.It \&Fl \&Ar outfile
266 You may assume that the width calculated by the string literal
268 will be covered by the \-width argument.