1 .\" $Id: manuals.7,v 1.10 2009/03/26 23:01:26 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 26 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
35 This document serves as a tutorial to writing
41 Prepare your composition environment by copying over the manual template
43 .Pa /usr/share/misc/mdoc.template .
45 If this file doesn't exist, bug your administrator.
47 start afresh or by copying another manual unless you know exactly what
51 Find an appropriate section for your manual. There may exist multiple
52 manual names per section, so be specific:
55 .Bl -tag -width "XXXXXXXXXXXX" -offset indent -compact
63 programming libraries (C, Perl, Fortran)
65 file and wire protocol formats
69 tutorials, documents and papers
71 administrator utilities
76 If your manual falls into multiple categories, choose the most
77 widely-used or, better, re-consider the topic of your manual to be more
78 specific. You can list all manuals per section by invoking
84 to see the specific section manual (section 1, in this example):
86 .Bd -literal -offset indent
88 myname (1) - utility description
89 myname (3) - library description
94 Name your component. Be terse, erring on the side of clarity. Look for
95 other manuals by that same name before committing:
99 Manual files are named
100 .Pa myname.mysection ,
112 There exist other documentation-specific languages, such as the
117 newer languages such as DocBook or texinfo; or even ad-hoc conventions
118 such as README files.
119 .Em Avoid these formats .
121 There are two canonical references for writing mdoc. Read them.
124 .Bl -tag -width XXXXXXXXXXXXXXXX -offset indent -compact
126 formal language reference
127 .It Xr mdoc.samples 7
131 Open the template you've copied into
135 .Ss Development Tools
136 While writing, make sure that your manual is correctly structured:
138 .Dl % mandoc \-Tlint \-Wall name.1
140 You may spell-check your work as follows:
142 .Dl % deroff name.1 | spell
143 .Dl % ispell \-n name.1
149 to version-control your work. If you wish the last check-in to effect
150 your document's date, use the following RCS tag for the date macro:
152 .Dl \&.Dd $Mdocdate: March 26 2009 $
155 mdoc documents may be paged to your terminal with
157 If you plan on distributing your work to systems without this tool,
160 .Bd -literal -offset indent
161 % mandoc \-Wall name.1 2>&1 | less
162 % groff -mandoc name.1 2>&1 | less
166 Consider adding your mdoc documents to
168 Makefiles in order to automatically check your input:
169 .Bd -literal -offset indent
173 mandoc -Wall,error -Tlint $<
178 Your manual must have a license. It should be listed at the start of
179 your document, just as in source code.
186 files are indispensable in guiding composition. In this section, we
189 manual best practices:
194 Use clear, concise language. Favour simplicity.
196 Write your manual in non-idiomatic English. Don't worry about
197 Commonwealth or American spellings \(em just correct ones.
199 Spell-check your manual, keeping in mind short-letter terms (
204 If you absolutely must use special characters (diacritics, mathematical
205 symbols and so on), use the escapes dictated in
210 The structure of the mdoc language makes it very hard to have any
211 particular format style. Keep your lines under 72 characters in length.
212 If you must have long option lines, use
214 The same goes for function prototypes.
218 Find another way to structure your line.
221 Other components may be referenced with the
225 macros. Make sure that these exist. If you intend to distribute your
228 references are valid across systems (within reason). If you cross-link with
230 make sure that the section reference exists.
233 Cite your work. If your system references standards documents or other
234 publications, please use the
239 .Em Don't style your manual .
240 Give it meaningful content. The front-end will worry about formatting
244 As your component changes and bugs are fixed, your manual may become out
245 of date. You may be tempted to use automation tools like Doxygen to
246 smooth the development of your manuals. Don't. Source documentation is
247 different from a component manual.