Annotation of mandoc/manuals.7, Revision 1.16
1.16 ! kristaps 1: .\" $Id: manuals.7,v 1.15 2009/06/25 10:55:40 kristaps Exp $
1.8 kristaps 2: .\"
1.14 kristaps 3: .\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
1.8 kristaps 4: .\"
5: .\" Permission to use, copy, modify, and distribute this software for any
1.13 kristaps 6: .\" purpose with or without fee is hereby granted, provided that the above
7: .\" copyright notice and this permission notice appear in all copies.
1.8 kristaps 8: .\"
1.13 kristaps 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.
1.8 kristaps 16: .\"
1.1 kristaps 17: .Dd $Mdocdate$
1.12 kristaps 18: .Dt MANUALS 7
1.1 kristaps 19: .Os
1.2 kristaps 20: .\" SECTION
1.1 kristaps 21: .Sh NAME
1.2 kristaps 22: .Nm Writing UNIX Documentation
23: .Nd a guide to writing UNIX manuals
24: .\" SECTION
1.1 kristaps 25: .Sh DESCRIPTION
1.2 kristaps 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
1.10 kristaps 31: importantly, a game.
1.2 kristaps 32: .Pp
33: This document serves as a tutorial to writing
34: .Ux
35: documentation
36: .Pq Dq manuals .
37: .\" SECTION
1.16 ! kristaps 38: .Sh ENVIRONMENT
1.11 kristaps 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 \.
1.8 kristaps 44: .Pp
1.5 kristaps 45: .Em \&Do not
46: start afresh or by copying another manual unless you know exactly what
1.11 kristaps 47: you're doing! If the template doesn't exist, bug your administrator.
1.5 kristaps 48: .\" SUBSECTION
49: .Ss Section Numbering
50: Find an appropriate section for your manual. There may exist multiple
1.10 kristaps 51: manual names per section, so be specific:
1.2 kristaps 52: .Pp
1.5 kristaps 53: .\" LIST
1.2 kristaps 54: .Bl -tag -width "XXXXXXXXXXXX" -offset indent -compact
55: .It Em Section
56: .Em Description
57: .It 1
58: operator utilities
1.3 kristaps 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
1.2 kristaps 69: .It 8
70: administrator utilities
1.3 kristaps 71: .It 9
72: in-kernel routines
1.2 kristaps 73: .El
74: .Pp
1.5 kristaps 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
1.7 kristaps 87: myname (1) - utility description
88: myname (3) - library description
1.5 kristaps 89: % man \-s 1 myname
90: .Ed
1.2 kristaps 91: .\" SUBSECTION
92: .Ss Naming
1.10 kristaps 93: Name your component. Be terse, erring on the side of clarity. Look for
94: other manuals by that same name before committing:
1.2 kristaps 95: .Pp
96: .Dl % apropos myname
97: .Pp
1.5 kristaps 98: Manual files are named
99: .Pa myname.mysection ,
1.2 kristaps 100: such as
101: .Pa manuals.7
1.11 kristaps 102: for this document. Rename the template file:
103: .Pp
104: .Dl % mv mdoc.template myname.mysection
1.2 kristaps 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
1.11 kristaps 114: .Pp
115: If
116: .Xr ispell 1
117: is installed, it has a special mode for manuals:
118: .Pp
1.2 kristaps 119: .Dl % ispell \-n name.1
120: .Pp
121: Use
122: .Xr cvs 1
1.10 kristaps 123: or
1.2 kristaps 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$
129: .\" SUBSECTION
130: .Ss Viewing
1.10 kristaps 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 :
1.2 kristaps 136: .Bd -literal -offset indent
1.10 kristaps 137: % mandoc \-Wall name.1 2>&1 | less
138: % groff -mandoc name.1 2>&1 | less
1.2 kristaps 139: .Ed
140: .\" SUBSECTION
141: .Ss Automation
142: Consider adding your mdoc documents to
143: .Xr make 1
1.10 kristaps 144: Makefiles in order to automatically check your input:
1.2 kristaps 145: .Bd -literal -offset indent
1.10 kristaps 146: \&.SUFFIXES: .1 .in
1.1 kristaps 147:
1.2 kristaps 148: \&.in.1:
149: mandoc -Wall,error -Tlint $<
150: cp -f $< $@
151: .Ed
1.8 kristaps 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.
1.2 kristaps 156: .\" SECTION
1.16 ! kristaps 157: .Sh COMPOSITION
! 158: Manuals should
! 159: .Em always
! 160: be written in the
1.2 kristaps 161: .Xr mdoc 7
1.16 ! kristaps 162: formatting language.
! 163: .\" PARAGRAPH
! 164: .Pp
! 165: Open the template you've copied into
! 166: .Pa myname.mysection
! 167: and begin editing.
1.2 kristaps 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
1.8 kristaps 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 .
1.10 kristaps 192: The same goes for function prototypes.
1.8 kristaps 193: .Em \&Do not
194: use
1.10 kristaps 195: .Sq \&Xo/Xc .
196: Find another way to structure your line.
1.8 kristaps 197: .\" SUBSECTION
1.2 kristaps 198: .Ss References
199: Other components may be referenced with the
1.5 kristaps 200: .Sq \&Xr
1.2 kristaps 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
1.3 kristaps 216: .Ss Formatting
1.10 kristaps 217: .Em Don't style your manual .
1.6 kristaps 218: Give it meaningful content. The front-end will worry about formatting
219: and style.
1.5 kristaps 220: .\" SECTION
221: .Sh MAINTENANCE
222: As your component changes and bugs are fixed, your manual may become out
1.11 kristaps 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.
CVSweb