]>
Commit | Line | Data |
---|---|---|
1 | .\" (C) Copyright 1992-1999 Rickard E. Faith and David A. Wheeler | |
2 | .\" (faith@cs.unc.edu and dwheeler@ida.org) | |
3 | .\" and (C) Copyright 2007 Michael Kerrisk <mtk-manpages@gmx.net> | |
4 | .\" | |
5 | .\" Permission is granted to make and distribute verbatim copies of this | |
6 | .\" manual provided the copyright notice and this permission notice are | |
7 | .\" preserved on all copies. | |
8 | .\" | |
9 | .\" Permission is granted to copy and distribute modified versions of this | |
10 | .\" manual under the conditions for verbatim copying, provided that the | |
11 | .\" entire resulting derived work is distributed under the terms of a | |
12 | .\" permission notice identical to this one. | |
13 | .\" | |
14 | .\" Since the Linux kernel and libraries are constantly changing, this | |
15 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
16 | .\" responsibility for errors or omissions, or for damages resulting from | |
17 | .\" the use of the information contained herein. The author(s) may not | |
18 | .\" have taken the same level of care in the production of this manual, | |
19 | .\" which is licensed free of charge, as they might when working | |
20 | .\" professionally. | |
21 | .\" | |
22 | .\" Formatted or processed versions of this manual, if unaccompanied by | |
23 | .\" the source, must acknowledge the copyright and authors of this work. | |
24 | .\" | |
25 | .\" 2007-05-30 created by mtk, using text from old man.7 plus | |
26 | .\" rewrites and additional text. | |
27 | .\" | |
28 | .TH MAN-PAGES 7 2007-05-30 "Linux" "Linux Programmer's Manual" | |
29 | .SH NAME | |
30 | man-pages \- conventions for writing Linux man pages | |
31 | .SH SYNOPSIS | |
32 | .B man | |
33 | .RI [ section ] | |
34 | .I title | |
35 | .SH DESCRIPTION | |
36 | This page describes the conventions that should be employed | |
37 | when writing man pages for the Linux \fIman-pages\fP project, | |
38 | which comprises Sections 2, 3, 4, 5, and 7 of the Linux manual pages. | |
39 | The conventions described on this page may also be useful | |
40 | for authors writing man pages for other projects. | |
41 | .SS Sections of the Manual Pages | |
42 | .PP | |
43 | The manual Sections are traditionally defined as follows: | |
44 | .TP 10 | |
45 | .B 1 Commands (Programs) | |
46 | Those commands that can be executed by the user from within | |
47 | a shell. | |
48 | .TP | |
49 | .B 2 System calls | |
50 | Those functions which must be performed by the kernel. | |
51 | .TP | |
52 | .B 3 Library calls | |
53 | Most of the | |
54 | .I libc | |
55 | functions. | |
56 | .TP | |
57 | .B 4 Special files (devices) | |
58 | Files found in | |
59 | .IR /dev . | |
60 | .TP | |
61 | .B 5 File formats and conventions | |
62 | The format for | |
63 | .I /etc/passwd | |
64 | and other human-readable files. | |
65 | .TP | |
66 | .B 6 Games | |
67 | .TP | |
68 | .B 7 Conventions and miscellaneous | |
69 | Overviews of various topics, conventions and protocols, | |
70 | character set standards, and miscellaneous other things. | |
71 | .TP | |
72 | .B 8 System management commands | |
73 | Commands like | |
74 | .BR mount (8), | |
75 | many of which only root can execute. | |
76 | .\" .TP | |
77 | .\" .B 9 Kernel routines | |
78 | .\" This is an obsolete manual section. | |
79 | .\" Once it was thought a good idea to document the Linux kernel here, | |
80 | .\" but in fact very little has been documented, and the documentation | |
81 | .\" that exists is outdated already. | |
82 | .\" There are better sources of | |
83 | .\" information for kernel developers. | |
84 | .SS Macro package | |
85 | New manual pages should be marked up using the | |
86 | .B groff tmac.an | |
87 | package described in | |
88 | .BR man (7). | |
89 | This choice is mainly for consistency: the vast majority of | |
90 | existing Linux manual pages are marked up using these macros. | |
91 | .SS Conventions for source file layout | |
92 | Please limit source code line length to no more than about 75 characters | |
93 | wherever possible. | |
94 | This helps avoid line-wrapping in some mail clients when patches are | |
95 | submitted inline. | |
96 | ||
97 | New sentences should be started on new lines. | |
98 | This makes it easier to see the effect of patches, | |
99 | which often operate at the level of individual sentences. | |
100 | .SS Title line | |
101 | The first command in a man page should be a \fBTH\fP command: | |
102 | .RS | |
103 | .sp | |
104 | .B \&.TH | |
105 | .IR "title section date source manual" | |
106 | .sp | |
107 | .RE | |
108 | where: | |
109 | .RS | |
110 | .TP 10 | |
111 | .I title | |
112 | The title of the man page, written in all caps (e.g., | |
113 | .IR MAN-PAGES ). | |
114 | .TP | |
115 | .I section | |
116 | The section number in which the man page should be placed (e.g., | |
117 | .IR 7 ). | |
118 | .TP | |
119 | .I date | |
120 | The date of the last revision\(emremember to change this every time a | |
121 | change is made to the man page, | |
122 | since this is the most general way of doing version control. | |
123 | Dates should be written in the form YYYY-MM-DD. | |
124 | .TP | |
125 | .I source | |
126 | The source of the command, function, or system call. | |
127 | .sp | |
128 | For those few \fIman-pages\fP pages in Sections 1 and 8, | |
129 | probably you just want to write | |
130 | .IR GNU . | |
131 | .sp | |
132 | For system calls, just write | |
133 | .IR "Linux" . | |
134 | (An earlier practice was to write the version number | |
135 | of the kernel from which the manual page was being written/checked. | |
136 | However, this was never done consistently, and so was | |
137 | probably worse than including no version number. | |
138 | Henceforth, avoid including a version number.) | |
139 | .sp | |
140 | For library calls that are part of glibc or one of the | |
141 | other common GNU libraries, just use | |
142 | .IR "GNU C Library" ", " GNU , | |
143 | or an empty string. | |
144 | .sp | |
145 | For Section 4 pages, use | |
146 | .IR "Linux" . | |
147 | .sp | |
148 | In cases of doubt, just write | |
149 | .IR Linux ", or " GNU . | |
150 | .TP | |
151 | .I manual | |
152 | The title of the manual (e.g., for Section 2 and 3 pages in | |
153 | the \fIman-pages\fP package, use | |
154 | .IR "Linux Programmer's Manual" ). | |
155 | .RE | |
156 | .SS Sections within a manual page | |
157 | The list below shows conventional or suggested sections. | |
158 | Most manual pages should include at least the | |
159 | .B highlighted | |
160 | sections. | |
161 | Arrange a new manual page so that sections | |
162 | are placed in the order shown in the list. | |
163 | .in +0.5i | |
164 | .nf | |
165 | ||
166 | \fBNAME\fP | |
167 | \fBSYNOPSIS\fP | |
168 | \fBDESCRIPTION\fP | |
169 | OPTIONS [Normally only in Sections 1, 8] | |
170 | EXIT STATUS [Normally only in Sections 1, 8] | |
171 | RETURN VALUE [Normally only in Sections 2, 3] | |
172 | .\" May 07: Few current man pages have an ERROR HANDLING section,,, | |
173 | .\" ERROR HANDLING, | |
174 | ERRORS [Typically only in Sections 2, 3] | |
175 | .\" May 07: Almost no current man pages have a USAGE section,,, | |
176 | .\" USAGE, | |
177 | ..\" DIAGNOSTICS, | |
178 | .\" May 07: Almost no current man pages have a SECURITY section,,, | |
179 | .\" SECURITY, | |
180 | ENVIRONMENT | |
181 | FILES | |
182 | VERSIONS [Normally only in Sections 2, 3] | |
183 | CONFORMING TO | |
184 | NOTES | |
185 | BUGS | |
186 | EXAMPLE | |
187 | .\" AUTHOR sections are discouraged | |
188 | .\" AUTHOR [Discouraged] | |
189 | \fBSEE ALSO\fP | |
190 | ||
191 | .fi | |
192 | .in | |
193 | .IR "Where a traditional heading would apply" ", " "please use it" ; | |
194 | this kind of consistency can make the information easier to understand. | |
195 | If you must, you can create your own | |
196 | headings if they make things easier to understand (this can | |
197 | be especially useful for pages in Sections 4 and 5). | |
198 | However, before doing this, consider whether you could use the | |
199 | traditional headings, with some subsections (\fI.SS\fP) within | |
200 | those sections. | |
201 | ||
202 | The following list elaborates on the contents of each of | |
203 | the above sections. | |
204 | .TP 14 | |
205 | .B NAME | |
206 | The name of this manual page. | |
207 | See | |
208 | .BR man (7) | |
209 | for important details of the line(s) that should follow the | |
210 | \fB.SH NAME\fI command. | |
211 | .TP | |
212 | .B SYNOPSIS | |
213 | briefly describes the command or function's interface. | |
214 | For commands, this shows the syntax of the command and its arguments | |
215 | (including options); | |
216 | boldface is used for as-is text and italics are used to | |
217 | indicate replaceable arguments. | |
218 | Brackets ([]) surround optional arguments, vertical bars (|) | |
219 | separate choices, and ellipses (\&...) can be repeated. | |
220 | For functions, it shows any required data declarations or | |
221 | .B #include | |
222 | directives, followed by the function declaration. | |
223 | .TP | |
224 | .B DESCRIPTION | |
225 | gives an explanation of what the program, function, or format does. | |
226 | Discuss how it interacts with files and standard input, and what it | |
227 | produces on standard output or standard error. | |
228 | Omit internals and implementation details unless they're critical for | |
229 | understanding the interface. | |
230 | Describe the usual case; | |
231 | for information on command-line options of a program use the | |
232 | .B OPTIONS | |
233 | section. | |
234 | .\" If there is some kind of input grammar or complex set of subcommands, | |
235 | .\" consider describing them in a separate | |
236 | .\" .B USAGE | |
237 | .\" section (and just place an overview in the | |
238 | .\" .B DESCRIPTION | |
239 | .\" section). | |
240 | .TP | |
241 | .B OPTIONS | |
242 | describes the command-line options accepted by a | |
243 | program and how they change its behavior. | |
244 | This section should only appear for Section 1 and 8 manual pages. | |
245 | .\" .TP | |
246 | .\" .B USAGE | |
247 | .\" describes the grammar of any sublanguage this implements. | |
248 | .TP | |
249 | .B EXIT STATUS | |
250 | lists the possible exit status values of a program and | |
251 | the conditions that cause these values to be returned. | |
252 | This section should only appear for Section 1 and 8 manual pages. | |
253 | .TP | |
254 | .B RETURN VALUE | |
255 | For Section 2 and 3 pages, this section gives a | |
256 | list of the values the library routine will return to the caller | |
257 | and the conditions that cause these values to be returned. | |
258 | .TP | |
259 | .B ERRORS | |
260 | For Section 2 and 3 manual pages, this is a list of the | |
261 | values that may be placed in | |
262 | .I errno | |
263 | in the event of an error, along with information about the cause | |
264 | of the errors. | |
265 | .IR "The error list should be in alphabetical order" . | |
266 | .TP | |
267 | .B ENVIRONMENT | |
268 | lists all environment variables that affect the program or function | |
269 | and how they affect it. | |
270 | .TP | |
271 | .B FILES | |
272 | lists the files the program or function uses, such as | |
273 | configuration files, startup files, | |
274 | and files the program directly operates on. | |
275 | Give the full pathname of these files, and use the installation | |
276 | process to modify the directory part to match user preferences. | |
277 | For many programs, the default installation location is in | |
278 | .IR /usr/local , | |
279 | so your base manual page should use | |
280 | .I /usr/local | |
281 | as the base. | |
282 | .\" May 07: Almost no current man pages have a DIAGNOSTICS section; | |
283 | .\" "RETURN VALUE" or "EXIT STATUS" is preferred. | |
284 | .\" .TP | |
285 | .\" .B DIAGNOSTICS | |
286 | .\" gives an overview of the most common error messages and how to | |
287 | .\" cope with them. | |
288 | .\" You don't need to explain system error messages | |
289 | .\" or fatal signals that can appear during execution of any program | |
290 | .\" unless they're special in some way to the program. | |
291 | .\" | |
292 | .\" May 07: Almost no current man pages have a SECURITY section. | |
293 | .\".TP | |
294 | .\".B SECURITY | |
295 | .\"discusses security issues and implications. | |
296 | .\"Warn about configurations or environments that should be avoided, | |
297 | .\"commands that may have security implications, and so on, especially | |
298 | .\"if they aren't obvious. | |
299 | .\"Discussing security in a separate section isn't necessary; | |
300 | .\"if it's easier to understand, place security information in the | |
301 | .\"other sections (such as the | |
302 | .\" .B DESCRIPTION | |
303 | .\" or | |
304 | .\" .B USAGE | |
305 | .\" section). | |
306 | .\" However, please include security information somewhere! | |
307 | .TP | |
308 | .B VERSIONS | |
309 | A brief summary of the Linux kernel or glibc versions where a | |
310 | system call or library function appeared, | |
311 | or changed significantly in its operation. | |
312 | .TP | |
313 | .B CONFORMING TO | |
314 | describes any standards or conventions that relate to the function | |
315 | or command described by the manual page. | |
316 | For a page in Section 2 or 3, | |
317 | this section should note the POSIX.1 | |
318 | version(s) that the call conforms to, | |
319 | and also whether the call is specified in C99. | |
320 | (Don't worry too much about other standards like SUS, SUSv2, and XPG, | |
321 | or the SVr4 and 4.xBSD implementation standards, | |
322 | unless the call was specified in those standards, | |
323 | but isn't in the current version of POSIX.1.) | |
324 | (See | |
325 | .BR standards (7).) | |
326 | ||
327 | If the call is not governed by any standards but commonly | |
328 | exists on other systems, note them. | |
329 | If the call is Linux specific, note this. | |
330 | .TP | |
331 | .B NOTES | |
332 | provides miscellaneous notes. | |
333 | For Section 2 and 3 man pages you may find it useful to include | |
334 | subsections (\fBSS\fP) named \fILinux Notes\fP and \fIGlibc Notes\fP. | |
335 | .TP | |
336 | .B BUGS | |
337 | lists limitations, known defects or inconveniences, | |
338 | and other questionable activities. | |
339 | .TP | |
340 | .B EXAMPLE | |
341 | provides one or more examples describing how this function, file or | |
342 | command is used. | |
343 | For details on writing example programs, | |
344 | see \fIExample Programs\fP below. | |
345 | .TP | |
346 | .B AUTHOR | |
347 | lists authors of the documentation or program. | |
348 | \fBUse of an AUTHOR section is discouraged\fP. | |
349 | Generally, it is better not to clutter every page with a list | |
350 | of (over time potentially numerous) authors; | |
351 | if you write or significantly amend a page, | |
352 | add a copyright notice as a comment in the source file. | |
353 | If you are the author a device driver and what to include | |
354 | an address for reporting bugs, place this under the BUGS section. | |
355 | .TP | |
356 | .B SEE ALSO | |
357 | lists related man pages, ordered by section number and | |
358 | alphabetically by name, possibly followed by | |
359 | other related pages or documents. | |
360 | .SS Font conventions | |
361 | .PP | |
362 | For functions, the arguments are always specified using italics, | |
363 | .IR "even in the SYNOPSIS section" , | |
364 | where the rest of the function is specified in bold: | |
365 | .PP | |
366 | .RS | |
367 | .BI " int myfunction(int " argc ", char **" argv ); | |
368 | .RE | |
369 | .PP | |
370 | Filenames are always in italics (e.g., | |
371 | .IR "/usr/include/stdio.h" ), | |
372 | except in the SYNOPSIS section, where included files are in bold (e.g., | |
373 | .BR "#include <stdio.h>" ). | |
374 | .PP | |
375 | Special macros, which are usually in upper case, are in bold (e.g., | |
376 | .BR MAXINT ). | |
377 | Exception: don't boldface NULL. | |
378 | .PP | |
379 | When enumerating a list of error codes, the codes are in bold (this list | |
380 | usually uses the | |
381 | .B \&.TP | |
382 | macro). | |
383 | .PP | |
384 | Any reference to the subject of the current manual page | |
385 | should be written with the name in bold. | |
386 | If the subject is a function (i.e., this is a Section 2 or 3 page), | |
387 | then the name should be followed by a pair of parentheses | |
388 | in Roman (normal) font. | |
389 | For example, in the | |
390 | .BR fcntl (2) | |
391 | man page, references to the subject of the page would be written as: | |
392 | .BR fcntl (). | |
393 | The preferred way to write this in the source file is: | |
394 | .nf | |
395 | ||
396 | .BR fcntl () | |
397 | ||
398 | .fi | |
399 | (Using this format, rather than the use of "\\fB...\\fP()" | |
400 | makes it easier to write tools that parse man page source files.) | |
401 | .PP | |
402 | Any reference to another man page | |
403 | should be written with the name in bold, | |
404 | \fIalways\fP followed by the section number, | |
405 | formatted in Roman (normal) font, without any | |
406 | separating spaces (e.g., | |
407 | .BR intro (2)). | |
408 | The preferred way to write this in the source file is: | |
409 | .nf | |
410 | ||
411 | .BR intro (2) | |
412 | ||
413 | .fi | |
414 | (Including the section number in cross references lets tools like | |
415 | .BR man2html (1) | |
416 | create properly hyperlinked pages.) | |
417 | .SS Spelling | |
418 | Staring with release 2.59, | |
419 | .I man-pages | |
420 | follows American spelling conventions; | |
421 | please write all new pages and patches according to these conventions. | |
422 | .SS Example Programs | |
423 | Manual pages can include example programs demonstrating how to | |
424 | use a system call or library function. | |
425 | However, note the following: | |
426 | .TP 3 | |
427 | * | |
428 | Example programs should be written in C. | |
429 | .TP | |
430 | * | |
431 | An example program is only necessary and useful if it demonstrates | |
432 | something beyond what can easily be provided in a textual | |
433 | description of the interface. | |
434 | An example program that does nothing | |
435 | other than call an interface usually serves little purpose. | |
436 | .TP | |
437 | * | |
438 | Example programs should be fairly short (preferably < 100 lines; | |
439 | ideally < 50 lines). | |
440 | .TP | |
441 | * | |
442 | Example programs should do error checking after system calls and | |
443 | library function calls. | |
444 | .TP | |
445 | * | |
446 | Example programs should be complete, and compile without | |
447 | warnings when compiled with \fIcc -Wall\fP. | |
448 | .TP | |
449 | * | |
450 | Where possible and appropriate, example programs should allow | |
451 | experimentation, by varying their behavior based on inputs | |
452 | (ideally from command-line arguments, or alternatively, via | |
453 | input read by the program). | |
454 | .TP | |
455 | * | |
456 | Example programs should be laid out according to Kernighan and | |
457 | Ritchie style, with 4-space indents. | |
458 | (Avoid the use of TAB characters in source code!) | |
459 | .PP | |
460 | For some examples of what example programs should look like, see | |
461 | .BR wait (2) | |
462 | and | |
463 | .BR pipe (2). | |
464 | .SH EXAMPLE | |
465 | For canonical examples of how man pages in the | |
466 | .IR man-pages | |
467 | package should look, see | |
468 | .BR pipe (2) | |
469 | and | |
470 | .BR fcntl (2). | |
471 | .SH SEE ALSO | |
472 | .BR man (1), | |
473 | .BR man2html (1), | |
474 | .BR man (7), | |
475 | .BR mdoc (7) |