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