1 .\" $Id: manuals.7,v 1.18 2009/07/27 13:10:08 kristaps Exp $
3 .\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
5 .\" Permission to use, copy, modify, and distribute this software for any
6 .\" purpose with or without fee is hereby granted, provided that the above
7 .\" copyright notice and this permission notice appear in all copies.
9 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 .Dd $Mdocdate: July 27 2009 $
22 .Nm Writing UNIX Documentation
23 .Nd a guide to writing UNIX manuals
26 .Em A utility without good documentation is of no utility at all .
29 A system component's documentation describes the utility of that
30 component, whether it's a device driver, an executable or, most
33 This document serves as a tutorial to writing
39 First, copy over the manual template from
40 .Pa /usr/share/misc/mdoc.template
41 into your source directory.
43 .Dl % cp /usr/share/misc/mdoc.template \.
46 start afresh or by copying another manual unless you know exactly what
47 you're doing! If the template doesn't exist, bug your administrator.
50 Find an appropriate section for your manual. There may exist multiple
51 manual names per section, so be specific:
54 .Bl -tag -width "XXXXXXXXXXXX" -offset indent -compact
62 programming libraries (C, Perl, Fortran)
64 file and wire protocol formats
68 tutorials, documents and papers
70 administrator utilities
75 If your manual falls into multiple categories, choose the most
76 widely-used or, better, re-consider the topic of your manual to be more
77 specific. You can list all manuals per section by invoking
83 to see the specific section manual (section 1, in this example):
85 .Bd -literal -offset indent
87 myname (1) - utility description
88 myname (3) - library description
93 Name your component. Be terse, erring on the side of clarity. Look for
94 other manuals by that same name before committing:
98 Manual files are named
99 .Pa myname.mysection ,
102 for this document. Rename the template file:
104 .Dl % mv mdoc.template myname.mysection
106 .Ss Development Tools
107 While writing, make sure that your manual is correctly structured:
109 .Dl % mandoc \-Tlint \-Wall \-fstrict name.1
111 The quick-fix feature of
113 is useful for checking over many manuals:
114 .Bd -literal -offset indent
115 % mandoc \-Wall \-fstrict \-Tlint \-fign-errors \e
116 `find /usr/src \-name \e*\e.[1-9]` 2>&1 | \e
117 sed 's!^mandoc: !!' > /tmp/mandoc.errs
118 % vim -q /tmp/mandoc.errs
121 You may spell-check your work as follows:
123 .Dl % deroff name.1 | spell
127 is installed, it has a special mode for manuals:
129 .Dl % ispell \-n name.1
135 to version-control your work. If you wish the last check-in to effect
136 your document's date, use the following RCS tag for the date macro:
138 .Dl \&.Dd $Mdocdate: July 27 2009 $
141 mdoc documents may be paged to your terminal with
143 If you plan on distributing your work to systems without this tool,
146 .Bd -literal -offset indent
147 % mandoc \-Wall name.1 2>&1 | less
148 % groff -mandoc name.1 2>&1 | less
152 Consider adding your mdoc documents to
154 Makefiles in order to automatically check your input:
155 .Bd -literal -offset indent
159 mandoc -Wall,error -Tlint $<
164 Your manual must have a license. It should be listed at the start of
165 your document, just as in source code.
175 Open the template you've copied into
182 Use clear, concise language. Favour simplicity.
184 Write your manual in non-idiomatic English. Don't worry about
185 Commonwealth or American spellings \(em just correct ones.
187 Spell-check your manual, keeping in mind short-letter terms (
192 If you absolutely must use special characters (diacritics, mathematical
193 symbols and so on), use the escapes dictated in
198 The structure of the mdoc language makes it very hard to have any
199 particular format style. Keep your lines under 72 characters in length.
200 If you must have long option lines, use
202 The same goes for function prototypes.
206 Find another way to structure your line.
209 Other components may be referenced with the
213 macros. Make sure that these exist. If you intend to distribute your
216 references are valid across systems (within reason). If you cross-link with
218 make sure that the section reference exists.
221 Cite your work. If your system references standards documents or other
222 publications, please use the
227 .Em Don't style your manual .
228 Give it meaningful content. The front-end will worry about formatting
232 As your component changes and bugs are fixed, your manual may become out
233 of date. You may be tempted to use tools like Doxygen to automate the
234 development of your manuals. Don't.
236 .Em Manuals are part of a system component :
237 if you modify your code or specifications, modify the documentation.