]> git.cameronkatri.com Git - mandoc.git/blob - manuals.7
`An' gives correct error message in encountering arguments/parameters.
[mandoc.git] / manuals.7
1 .\" $Id: manuals.7,v 1.17 2009/07/20 13:45:11 kristaps Exp $
2 .\"
3 .\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
4 .\"
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.
8 .\"
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.
16 .\"
17 .Dd $Mdocdate: July 20 2009 $
18 .Dt MANUALS 7
19 .Os
20 .\" SECTION
21 .Sh NAME
22 .Nm Writing UNIX Documentation
23 .Nd a guide to writing UNIX manuals
24 .\" SECTION
25 .Sh DESCRIPTION
26 .Em A utility without good documentation is of no utility at all .
27 .\" PARAGRAPH
28 .Pp
29 A system component's documentation describes the utility of that
30 component, whether it's a device driver, an executable or, most
31 importantly, a game.
32 .Pp
33 This document serves as a tutorial to writing
34 .Ux
35 documentation
36 .Pq Dq manuals .
37 .\" SECTION
38 .Sh ENVIRONMENT
39 First, copy over the manual template from
40 .Pa /usr/share/misc/mdoc.template
41 into your source directory.
42 .Pp
43 .Dl % cp /usr/share/misc/mdoc.template \.
44 .Pp
45 .Em \&Do not
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.
48 .\" SUBSECTION
49 .Ss Section Numbering
50 Find an appropriate section for your manual. There may exist multiple
51 manual names per section, so be specific:
52 .Pp
53 .\" LIST
54 .Bl -tag -width "XXXXXXXXXXXX" -offset indent -compact
55 .It Em Section
56 .Em Description
57 .It 1
58 operator utilities
59 .It 2
60 system calls
61 .It 3, 3p, 3f
62 programming libraries (C, Perl, Fortran)
63 .It 5
64 file and wire protocol formats
65 .It 6
66 games
67 .It 7
68 tutorials, documents and papers
69 .It 8
70 administrator utilities
71 .It 9
72 in-kernel routines
73 .El
74 .Pp
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
78 .Xr apropos 1 ,
79 then provide the
80 .Fl s
81 flag to
82 .Xr man 1
83 to see the specific section manual (section 1, in this example):
84 .\" DISPLAY
85 .Bd -literal -offset indent
86 % apropos myname
87 myname (1) - utility description
88 myname (3) - library description
89 % man \-s 1 myname
90 .Ed
91 .\" SUBSECTION
92 .Ss Naming
93 Name your component. Be terse, erring on the side of clarity. Look for
94 other manuals by that same name before committing:
95 .Pp
96 .Dl % apropos myname
97 .Pp
98 Manual files are named
99 .Pa myname.mysection ,
100 such as
101 .Pa manuals.7
102 for this document. Rename the template file:
103 .Pp
104 .Dl % mv mdoc.template myname.mysection
105 .\" SUBSECTION
106 .Ss Development Tools
107 While writing, make sure that your manual is correctly structured:
108 .Pp
109 .Dl % mandoc \-Tlint \-Wall name.1
110 .Pp
111 You may spell-check your work as follows:
112 .Pp
113 .Dl % deroff name.1 | spell
114 .Pp
115 If
116 .Xr ispell 1
117 is installed, it has a special mode for manuals:
118 .Pp
119 .Dl % ispell \-n name.1
120 .Pp
121 Use
122 .Xr cvs 1
123 or
124 .Xr rcs 1
125 to version-control your work. If you wish the last check-in to effect
126 your document's date, use the following RCS tag for the date macro:
127 .Pp
128 .Dl \&.Dd $Mdocdate: July 20 2009 $
129 .\" SUBSECTION
130 .Ss Viewing
131 mdoc documents may be paged to your terminal with
132 .Xr mandoc 1 .
133 If you plan on distributing your work to systems without this tool,
134 check it against
135 .Xr groff 1 :
136 .Bd -literal -offset indent
137 % mandoc \-Wall name.1 2>&1 | less
138 % groff -mandoc name.1 2>&1 | less
139 .Ed
140 .\" SUBSECTION
141 .Ss Automation
142 Consider adding your mdoc documents to
143 .Xr make 1
144 Makefiles in order to automatically check your input:
145 .Bd -literal -offset indent
146 \&.SUFFIXES: .1 .in
147
148 \&.in.1:
149 mandoc -Wall,error -Tlint $<
150 cp -f $< $@
151 .Ed
152 .\" SUBSECTION
153 .Ss Licensing
154 Your manual must have a license. It should be listed at the start of
155 your document, just as in source code.
156 .\" SECTION
157 .Sh COMPOSITION
158 Manuals should
159 .Em always
160 be written in the
161 .Xr mdoc 7
162 formatting language.
163 .\" PARAGRAPH
164 .Pp
165 Open the template you've copied into
166 .Pa myname.mysection
167 and begin editing.
168 .\" SUBSECTION
169 .Ss Language
170 .Bl -enum
171 .It
172 Use clear, concise language. Favour simplicity.
173 .It
174 Write your manual in non-idiomatic English. Don't worry about
175 Commonwealth or American spellings \(em just correct ones.
176 .It
177 Spell-check your manual, keeping in mind short-letter terms (
178 .Xr iwi 4
179 vs.
180 .Xr iwn 4 ) .
181 .It
182 If you absolutely must use special characters (diacritics, mathematical
183 symbols and so on), use the escapes dictated in
184 .Xr mdoc 7 .
185 .El
186 .\" SUBSECTION
187 .Ss Style
188 The structure of the mdoc language makes it very hard to have any
189 particular format style. Keep your lines under 72 characters in length.
190 If you must have long option lines, use
191 .Sq \&Oo/Oc .
192 The same goes for function prototypes.
193 .Em \&Do not
194 use
195 .Sq \&Xo/Xc .
196 Find another way to structure your line.
197 .\" SUBSECTION
198 .Ss References
199 Other components may be referenced with the
200 .Sq \&Xr
201 and
202 .Sq \&Sx
203 macros. Make sure that these exist. If you intend to distribute your
204 manual, make sure
205 .Sq \&Xr
206 references are valid across systems (within reason). If you cross-link with
207 .Sq \&Sx ,
208 make sure that the section reference exists.
209 .\" SUBSECTION
210 .Ss Citations
211 Cite your work. If your system references standards documents or other
212 publications, please use the
213 .Sq \&Rs/Re
214 block macros.
215 .\" SUBSECTION
216 .Ss Formatting
217 .Em Don't style your manual .
218 Give it meaningful content. The front-end will worry about formatting
219 and style.
220 .\" SECTION
221 .Sh MAINTENANCE
222 As your component changes and bugs are fixed, your manual may become out
223 of date. You may be tempted to use tools like Doxygen to automate the
224 development of your manuals. Don't.
225 .Pp
226 .Em Manuals are part of a system component :
227 if you modify your code or specifications, modify the documentation.