1 .\" $Id: manuals.7,v 1.8 2009/03/23 09:42:43 kristaps Exp $
3 .\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@openbsd.org>
5 .\" Permission to use, copy, modify, and distribute this software for any
6 .\" purpose with or without fee is hereby granted, provided that the
7 .\" above copyright notice and this permission notice appear in all
10 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11 .\" WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13 .\" AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14 .\" DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15 .\" PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16 .\" TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 .\" PERFORMANCE OF THIS SOFTWARE.
19 .Dd $Mdocdate: March 23 2009 $
24 .Nm Writing UNIX Documentation
25 .Nd a guide to writing UNIX manuals
28 .Em A utility without good documentation is of no utility at all .
31 A system component's documentation describes the utility of that
32 component, whether it's a device driver, an executable or, most
33 importantly, a game. Although there are plenty of documents available
36 documents, or where to find them, few focus on composition.
39 This document serves as a tutorial to writing
43 If you add something to your operating system, whether it's a new file
44 format or directory structure or device driver, it needs documentation.
47 Prepare your composition environment by copying over the manual template
49 .Pa /usr/share/misc/mdoc.template .
51 If this file doesn't exist, bug your administrator.
53 start afresh or by copying another manual unless you know exactly what
57 Find an appropriate section for your manual. There may exist multiple
58 manual names per section, so be specific. A table of all available
59 manual sections follows:
62 .Bl -tag -width "XXXXXXXXXXXX" -offset indent -compact
70 programming libraries (C, Perl, Fortran)
72 file and wire protocol formats
76 tutorials, documents and papers
78 administrator utilities
83 If your manual falls into multiple categories, choose the most
84 widely-used or, better, re-consider the topic of your manual to be more
85 specific. You can list all manuals per section by invoking
91 to see the specific section manual (section 1, in this example):
93 .Bd -literal -offset indent
95 myname (1) - utility description
96 myname (3) - library description
101 Name your component. Be terse, erring on the side of clarity. You may
102 want to look for other manuals by that same name before committing:
106 Manual files are named
107 .Pa myname.mysection ,
119 There exist other documentation-specific languages, such as the
127 newer languages such as DocBook, texinfo or schema-driven XML; or even
128 ad-hoc conventions such as README files.
129 .Em Avoid these formats .
130 Historical formats fail to capture a manual's semantic content, instead
131 only modelling its style. Newer methods requires special,
132 system-specific tools and may change or become obsolete over the
133 life-time of your component.
135 There are two canonical references for writing mdoc. Read them.
138 .Bl -tag -width XXXXXXXXXXXXXXXX -offset indent -compact
140 formal language reference
141 .It Xr mdoc.samples 7
145 Open the template you've copied into
149 .Ss Development Tools
150 While writing, make sure that your manual is correctly structured:
152 .Dl % mandoc \-Tlint \-Wall name.1
154 You may spell-check your work as follows:
156 .Dl % deroff name.1 | spell
157 .Dl % ispell \-n name.1
161 or, if not available,
163 to version-control your work. If you wish the last check-in to effect
164 your document's date, use the following RCS tag for the date macro:
166 .Dl \&.Dd $Mdocdate: March 23 2009 $
168 If using version control, the first line in your manual should be a
170 .Li $Id: manuals.7,v 1.8 2009/03/23 09:42:43 kristaps Exp $
174 mdoc documents may be paged to your terminal with traditional
178 or with newer, more powerful tools such as
181 .Bd -literal -offset indent
182 % nroff \-mandoc name.1 | less
183 % groff \-Tascii \-mandoc name.1 | less
184 % mandoc name.1 | less
187 Other output formats are also supported:
189 .Bd -literal -offset indent
190 % groff \-Tps \-mandoc name.1 | less
191 % mandoc \-Thtml name.1 | less
195 Consider adding your mdoc documents to
197 Makefiles in order to automatically check your input and generate
199 .Bd -literal -offset indent
200 \&.SUFFIXES: .html .txt .1 .in
203 mandoc -Wall,error -Tlint $<
208 mandoc -Tascii $< | col -b >$@
212 Your manual must have a license. It should be listed at the start of
213 your document, just as in source code.
220 files are indispensable in guiding composition. In this section, we
223 manual best practices:
228 Use clear, concise language. Favour simplicity.
230 Write your manual in non-idiomatic English. Don't worry about
231 Commonwealth or American spellings \(em just correct ones.
233 Spell-check your manual, keeping in mind short-letter terms (
238 If you absolutely must use special characters (diacritics, mathematical
239 symbols and so on), use the escapes dictated in
244 The structure of the mdoc language makes it very hard to have any
245 particular format style. Keep your lines under 72 characters in length.
246 If you must have long option lines, use
251 instead, either fine another way to write long lines, or, at the
252 absolute worst, use CPP-style newline escapes.
255 Other components may be referenced with the
259 macros. Make sure that these exist. If you intend to distribute your
262 references are valid across systems (within reason). If you cross-link with
264 make sure that the section reference exists.
267 Cite your work. If your system references standards documents or other
268 publications, please use the
273 .Em Don't style your manual.
274 Give it meaningful content. The front-end will worry about formatting
278 As your component changes and bugs are fixed, your manual may become out
279 of date. You may be tempted to use automation tools like Doxygen to
280 smooth the development of your manuals. Don't. Source documentation is
281 different from a component manual.