]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man7/man-pages.7
Many pages: Fix style issues reported by `make lint-groff`
[thirdparty/man-pages.git] / man7 / man-pages.7
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@gmail.com>
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .\" 2007-05-30 created by mtk, using text from old man.7 plus
8 .\" rewrites and additional text.
9 .\"
10 .TH MAN-PAGES 7 2021-03-22 "Linux" "Linux Programmer's Manual"
11 .SH NAME
12 man-pages \- conventions for writing Linux man pages
13 .SH SYNOPSIS
14 .B man
15 .RI [ section ]
16 .I title
17 .SH DESCRIPTION
18 This page describes the conventions that should be employed
19 when writing man pages for the Linux \fIman-pages\fP project,
20 which documents the user-space API provided by the Linux kernel
21 and the GNU C library.
22 The project thus provides most of the pages in Section 2,
23 many of the pages that appear in Sections 3, 4, and 7,
24 and a few of the pages that appear in Sections 1, 5, and 8
25 of the man pages on a Linux system.
26 The conventions described on this page may also be useful
27 for authors writing man pages for other projects.
28 .SS Sections of the manual pages
29 The manual Sections are traditionally defined as follows:
30 .TP
31 .B 1 User commands (Programs)
32 Commands that can be executed by the user from within
33 a shell.
34 .TP
35 .B 2 System calls
36 Functions which wrap operations performed by the kernel.
37 .TP
38 .B 3 Library calls
39 All library functions excluding the system call wrappers
40 (Most of the
41 .I libc
42 functions).
43 .TP
44 .B 4 Special files (devices)
45 Files found in
46 .I /dev
47 which allow to access to devices through the kernel.
48 .TP
49 .B 5 File formats and configuration files
50 Describes various human-readable file formats and configuration files.
51 .TP
52 .B 6 Games
53 Games and funny little programs available on the system.
54 .TP
55 .B 7 Overview, conventions, and miscellaneous
56 Overviews or descriptions of various topics, conventions, and protocols,
57 character set standards, the standard filesystem layout, and miscellaneous
58 other things.
59 .TP
60 .B 8 System management commands
61 Commands like
62 .BR mount (8),
63 many of which only root can execute.
64 .\" .TP
65 .\" .B 9 Kernel routines
66 .\" This is an obsolete manual section.
67 .\" Once it was thought a good idea to document the Linux kernel here,
68 .\" but in fact very little has been documented, and the documentation
69 .\" that exists is outdated already.
70 .\" There are better sources of
71 .\" information for kernel developers.
72 .SS Macro package
73 New manual pages should be marked up using the
74 .B groff an.tmac
75 package described in
76 .BR man (7).
77 This choice is mainly for consistency: the vast majority of
78 existing Linux manual pages are marked up using these macros.
79 .SS Conventions for source file layout
80 Please limit source code line length to no more than about 75 characters
81 wherever possible.
82 This helps avoid line-wrapping in some mail clients when patches are
83 submitted inline.
84 .SS Title line
85 The first command in a man page should be a
86 .B TH
87 command:
88 .PP
89 .RS
90 .B \&.TH
91 .I "title section date source manual"
92 .RE
93 .PP
94 The arguments of the command are as follows:
95 .TP
96 .I title
97 The title of the man page, written in all caps (e.g.,
98 .IR MAN-PAGES ).
99 .TP
100 .I section
101 The section number in which the man page should be placed (e.g.,
102 .IR 7 ).
103 .TP
104 .I date
105 The date of the last nontrivial change that was made to the man page.
106 (Within the
107 .I man-pages
108 project, the necessary updates to these timestamps are handled
109 automatically by scripts, so there is no need to manually update
110 them as part of a patch.)
111 Dates should be written in the form YYYY-MM-DD.
112 .TP
113 .I source
114 The source of the command, function, or system call.
115 .IP
116 For those few \fIman-pages\fP pages in Sections 1 and 8,
117 probably you just want to write
118 .IR GNU .
119 .IP
120 For system calls, just write
121 .IR "Linux" .
122 (An earlier practice was to write the version number
123 of the kernel from which the manual page was being written/checked.
124 However, this was never done consistently, and so was
125 probably worse than including no version number.
126 Henceforth, avoid including a version number.)
127 .IP
128 For library calls that are part of glibc or one of the
129 other common GNU libraries, just use
130 .IR "GNU C Library" ", " GNU ,
131 or an empty string.
132 .IP
133 For Section 4 pages, use
134 .IR "Linux" .
135 .IP
136 In cases of doubt, just write
137 .IR Linux ", or " GNU .
138 .TP
139 .I manual
140 The title of the manual (e.g., for Section 2 and 3 pages in
141 the \fIman-pages\fP package, use
142 .IR "Linux Programmer's Manual" ).
143 .\"
144 .SS Sections within a manual page
145 The list below shows conventional or suggested sections.
146 Most manual pages should include at least the
147 .B highlighted
148 sections.
149 Arrange a new manual page so that sections
150 are placed in the order shown in the list.
151 .PP
152 .RS
153 .TS
154 l l.
155 \fBNAME\fP
156 LIBRARY [Normally only in Sections 2, 3]
157 \fBSYNOPSIS\fP
158 CONFIGURATION [Normally only in Section 4]
159 \fBDESCRIPTION\fP
160 OPTIONS [Normally only in Sections 1, 8]
161 EXIT STATUS [Normally only in Sections 1, 8]
162 RETURN VALUE [Normally only in Sections 2, 3]
163 .\" May 07: Few current man pages have an ERROR HANDLING section,,,
164 .\" ERROR HANDLING,
165 ERRORS [Typically only in Sections 2, 3]
166 .\" May 07: Almost no current man pages have a USAGE section,,,
167 .\" USAGE,
168 .\" DIAGNOSTICS,
169 .\" May 07: Almost no current man pages have a SECURITY section,,,
170 .\" SECURITY,
171 ENVIRONMENT
172 FILES
173 VERSIONS [Normally only in Sections 2, 3]
174 ATTRIBUTES [Normally only in Sections 2, 3]
175 CONFORMING TO
176 NOTES
177 BUGS
178 EXAMPLES
179 .\" AUTHORS sections are discouraged
180 AUTHORS [Discouraged]
181 REPORTING BUGS [Not used in man-pages]
182 COPYRIGHT [Not used in man-pages]
183 \fBSEE ALSO\fP
184 .TE
185 .RE
186 .PP
187 .IR "Where a traditional heading would apply" ", " "please use it" ;
188 this kind of consistency can make the information easier to understand.
189 If you must, you can create your own
190 headings if they make things easier to understand (this can
191 be especially useful for pages in Sections 4 and 5).
192 However, before doing this, consider whether you could use the
193 traditional headings, with some subsections (\fI.SS\fP) within
194 those sections.
195 .PP
196 The following list elaborates on the contents of each of
197 the above sections.
198 .TP
199 .B NAME
200 The name of this manual page.
201 .IP
202 See
203 .BR man (7)
204 for important details of the line(s) that should follow the
205 \fB.SH NAME\fP command.
206 All words in this line (including the word immediately
207 following the "\e\-") should be in lowercase,
208 except where English or technical terminological convention
209 dictates otherwise.
210 .TP
211 .B SYNOPSIS
212 A brief summary of the command or function's interface.
213 .IP
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 .IP
224 Where a feature test macro must be defined in order to obtain
225 the declaration of a function (or a variable) from a header file,
226 then the SYNOPSIS should indicate this, as described in
227 .BR feature_test_macros (7).
228 .\" FIXME . Say something here about compiler options
229 .TP
230 .B CONFIGURATION
231 Configuration details for a device.
232 .IP
233 This section normally appears only in Section 4 pages.
234 .TP
235 .B DESCRIPTION
236 An explanation of what the program, function, or format does.
237 .IP
238 Discuss how it interacts with files and standard input, and what it
239 produces on standard output or standard error.
240 Omit internals and implementation details unless they're critical for
241 understanding the interface.
242 Describe the usual case;
243 for information on command-line options of a program use the
244 .B OPTIONS
245 section.
246 .\" If there is some kind of input grammar or complex set of subcommands,
247 .\" consider describing them in a separate
248 .\" .B USAGE
249 .\" section (and just place an overview in the
250 .\" .B DESCRIPTION
251 .\" section).
252 .IP
253 When describing new behavior or new flags for
254 a system call or library function,
255 be careful to note the kernel or C library version
256 that introduced the change.
257 The preferred method of noting this information for flags is as part of a
258 .B .TP
259 list, in the following form (here, for a new system call flag):
260 .RS 16
261 .TP
262 .BR XYZ_FLAG " (since Linux 3.7)"
263 Description of flag...
264 .RE
265 .IP
266 Including version information is especially useful to users
267 who are constrained to using older kernel or C library versions
268 (which is typical in embedded systems, for example).
269 .TP
270 .B OPTIONS
271 A description of the command-line options accepted by a
272 program and how they change its behavior.
273 .IP
274 This section should appear only for Section 1 and 8 manual pages.
275 .\" .TP
276 .\" .B USAGE
277 .\" describes the grammar of any sublanguage this implements.
278 .TP
279 .B EXIT STATUS
280 A list of the possible exit status values of a program and
281 the conditions that cause these values to be returned.
282 .IP
283 This section should appear only for Section 1 and 8 manual pages.
284 .TP
285 .B RETURN VALUE
286 For Section 2 and 3 pages, this section gives a
287 list of the values the library routine will return to the caller
288 and the conditions that cause these values to be returned.
289 .TP
290 .B ERRORS
291 For Section 2 and 3 manual pages, this is a list of the
292 values that may be placed in
293 .I errno
294 in the event of an error, along with information about the cause
295 of the errors.
296 .IP
297 Where several different conditions produce the same error,
298 the preferred approach is to create separate list entries
299 (with duplicate error names) for each of the conditions.
300 This makes the separate conditions clear, may make the list easier to read,
301 and allows metainformation
302 (e.g., kernel version number where the condition first became applicable)
303 to be more easily marked for each condition.
304 .IP
305 .IR "The error list should be in alphabetical order" .
306 .TP
307 .B ENVIRONMENT
308 A list of all environment variables that affect the program or function
309 and how they affect it.
310 .TP
311 .B FILES
312 A list of the files the program or function uses, such as
313 configuration files, startup files,
314 and files the program directly operates on.
315 .IP
316 Give the full pathname of these files, and use the installation
317 process to modify the directory part to match user preferences.
318 For many programs, the default installation location is in
319 .IR /usr/local ,
320 so your base manual page should use
321 .I /usr/local
322 as the base.
323 .\" May 07: Almost no current man pages have a DIAGNOSTICS section;
324 .\" "RETURN VALUE" or "EXIT STATUS" is preferred.
325 .\" .TP
326 .\" .B DIAGNOSTICS
327 .\" gives an overview of the most common error messages and how to
328 .\" cope with them.
329 .\" You don't need to explain system error messages
330 .\" or fatal signals that can appear during execution of any program
331 .\" unless they're special in some way to the program.
332 .\"
333 .\" May 07: Almost no current man pages have a SECURITY section.
334 .\".TP
335 .\".B SECURITY
336 .\"discusses security issues and implications.
337 .\"Warn about configurations or environments that should be avoided,
338 .\"commands that may have security implications, and so on, especially
339 .\"if they aren't obvious.
340 .\"Discussing security in a separate section isn't necessary;
341 .\"if it's easier to understand, place security information in the
342 .\"other sections (such as the
343 .\" .B DESCRIPTION
344 .\" or
345 .\" .B USAGE
346 .\" section).
347 .\" However, please include security information somewhere!
348 .TP
349 .B ATTRIBUTES
350 A summary of various attributes of the function(s) documented on this page.
351 See
352 .BR attributes (7)
353 for further details.
354 .TP
355 .B VERSIONS
356 A brief summary of the Linux kernel or glibc versions where a
357 system call or library function appeared,
358 or changed significantly in its operation.
359 .IP
360 As a general rule, every new interface should
361 include a VERSIONS section in its manual page.
362 Unfortunately,
363 many existing manual pages don't include this information
364 (since there was no policy to do so when they were written).
365 Patches to remedy this are welcome,
366 but, from the perspective of programmers writing new code,
367 this information probably matters only in the case of kernel
368 interfaces that have been added in Linux 2.4 or later
369 (i.e., changes since kernel 2.2),
370 and library functions that have been added to glibc since version 2.1
371 (i.e., changes since glibc 2.0).
372 .IP
373 The
374 .BR syscalls (2)
375 manual page also provides information about kernel versions
376 in which various system calls first appeared.
377 .TP
378 .B CONFORMING TO
379 A description of any standards or conventions that relate to the function
380 or command described by the manual page.
381 .IP
382 The preferred terms to use for the various standards are listed as
383 headings in
384 .BR standards (7).
385 .IP
386 For a page in Section 2 or 3,
387 this section should note the POSIX.1
388 version(s) that the call conforms to,
389 and also whether the call is specified in C99.
390 (Don't worry too much about other standards like SUS, SUSv2, and XPG,
391 or the SVr4 and 4.xBSD implementation standards,
392 unless the call was specified in those standards,
393 but isn't in the current version of POSIX.1.)
394 .IP
395 If the call is not governed by any standards but commonly
396 exists on other systems, note them.
397 If the call is Linux-specific, note this.
398 .IP
399 If this section consists of just a list of standards
400 (which it commonly does),
401 terminate the list with a period (\(aq.\(aq).
402 .TP
403 .B NOTES
404 Miscellaneous notes.
405 .IP
406 For Section 2 and 3 man pages you may find it useful to include
407 subsections (\fBSS\fP) named \fILinux Notes\fP and \fIGlibc Notes\fP.
408 .IP
409 In Section 2, use the heading
410 .I "C library/kernel differences"
411 to mark off notes that describe the differences (if any) between
412 the C library wrapper function for a system call and
413 the raw system call interface provided by the kernel.
414 .TP
415 .B BUGS
416 A list of limitations, known defects or inconveniences,
417 and other questionable activities.
418 .TP
419 .B EXAMPLES
420 One or more examples demonstrating how this function, file, or
421 command is used.
422 .IP
423 For details on writing example programs,
424 see \fIExample programs\fP below.
425 .TP
426 .B AUTHORS
427 A list of authors of the documentation or program.
428 .IP
429 \fBUse of an AUTHORS section is strongly discouraged\fP.
430 Generally, it is better not to clutter every page with a list
431 of (over time potentially numerous) authors;
432 if you write or significantly amend a page,
433 add a copyright notice as a comment in the source file.
434 If you are the author of a device driver and want to include
435 an address for reporting bugs, place this under the BUGS section.
436 .TP
437 .B REPORTING BUGS
438 The
439 .I man-pages
440 project doesn't use a REPORTING BUGS section in manual pages.
441 Information on reporting bugs is instead supplied in the
442 script-generated COLOPHON section.
443 However, various projects do use a REPORTING BUGS section.
444 It is recommended to place it near the foot of the page.
445 .TP
446 .B COPYRIGHT
447 The
448 .I man-pages
449 project doesn't use a COPYRIGHT section in manual pages.
450 Copyright information is instead maintained in the page source.
451 In pages where this section is present,
452 it is recommended to place it near the foot of the page, just above SEE ALSO.
453 .TP
454 .B SEE ALSO
455 A comma-separated list of related man pages, possibly followed by
456 other related pages or documents.
457 .IP
458 The list should be ordered by section number and
459 then alphabetically by name.
460 Do not terminate this list with a period.
461 .IP
462 Where the SEE ALSO list contains many long manual page names,
463 to improve the visual result of the output, it may be useful to employ the
464 .I .ad l
465 (don't right justify)
466 and
467 .I .nh
468 (don't hyphenate)
469 directives.
470 Hyphenation of individual page names can be prevented
471 by preceding words with the string "\e%".
472 .IP
473 Given the distributed, autonomous nature of FOSS projects
474 and their documentation, it is sometimes necessary\(emand in many cases
475 desirable\(emthat the SEE ALSO section includes references to
476 manual pages provided by other projects.
477 .SH FORMATTING AND WORDING CONVENTIONS
478 The following subsections note some details for preferred formatting and
479 wording conventions in various sections of the pages in the
480 .I man-pages
481 project.
482 .SS SYNOPSIS
483 Wrap the function prototype(s) in a
484 .IR .nf / .fi
485 pair to prevent filling.
486 .PP
487 In general, where more than one function prototype is shown in the SYNOPSIS,
488 the prototypes should
489 .I not
490 be separated by blank lines.
491 However, blank lines (achieved using
492 .IR .PP )
493 may be added in the following cases:
494 .IP * 3
495 to separate long lists of function prototypes into related groups
496 (see for example
497 .BR list (3));
498 .IP *
499 in other cases that may improve readability.
500 .PP
501 In the SYNOPSIS, a long function prototype may need to be
502 continued over to the next line.
503 The continuation line is indented according to the following rules:
504 .IP 1. 3
505 If there is a single such prototype that needs to be continued,
506 then align the continuation line so that when the page is
507 rendered on a fixed-width font device (e.g., on an xterm) the
508 continuation line starts just below the start of the argument
509 list in the line above.
510 (Exception: the indentation may be
511 adjusted if necessary to prevent a very long continuation line
512 or a further continuation line where the function prototype is
513 very long.)
514 As an example:
515 .PP
516 .RS
517 .nf
518 .BI "int tcsetattr(int " fd ", int " optional_actions ,
519 .BI " const struct termios *" termios_p );
520 .fi
521 .RE
522 .IP 2. 3
523 But, where multiple functions in the SYNOPSIS require
524 continuation lines, and the function names have different
525 lengths, then align all continuation lines to start in the
526 same column.
527 This provides a nicer rendering in PDF output
528 (because the SYNOPSIS uses a variable width font where
529 spaces render narrower than most characters).
530 As an example:
531 .PP
532 .RS
533 .nf
534 .BI "int getopt(int " argc ", char * const " argv[] ,
535 .BI " const char *" optstring );
536 .BI "int getopt_long(int " argc ", char * const " argv[] ,
537 .BI " const char *" optstring ,
538 .BI " const struct option *" longopts ", int *" longindex );
539 .fi
540 .RE
541 .SS RETURN VALUE
542 The preferred wording to describe how
543 .I errno
544 is set is
545 .RI \(dq errno
546 is set to indicate the error"
547 or similar.
548 .\" Before man-pages 5.11, many different wordings were used, which
549 .\" was confusing, and potentially made scripted edits more difficult.
550 This wording is consistent with the wording used in both POSIX.1 and FreeBSD.
551 .SS ATTRIBUTES
552 .\" See man-pages commit c466875ecd64ed3d3cd3e578406851b7dfb397bf
553 Note the following:
554 .IP * 3
555 Wrap the table in this section in a
556 .IR ".ad\ l" / .ad
557 pair to disable text filling and a
558 .IR .nh / .hy
559 pair to disable hyphenation.
560 .IP *
561 Ensure that the table occupies the full page width through the use of an
562 .I lbx
563 description for one of the columns
564 (usually the first column,
565 though in some cases the last column if it contains a lot of text).
566 .IP *
567 Make free use of
568 .IR T{ / T}
569 macro pairs to allow table cells to be broken over multiple lines
570 (also bearing in mind that pages may sometimes be rendered to a
571 width of less than 80 columns).
572 .PP
573 For examples of all of the above, see the source code of various pages.
574 .SH STYLE GUIDE
575 The following subsections describe the preferred style for the
576 .I man-pages
577 project.
578 For details not covered below, the Chicago Manual of Style
579 is usually a good source;
580 try also grepping for preexisting usage in the project source tree.
581 .SS Use of gender-neutral language
582 As far as possible, use gender-neutral language in the text of man
583 pages.
584 Use of "they" ("them", "themself", "their") as a gender-neutral singular
585 pronoun is acceptable.
586 .\"
587 .SS Formatting conventions for manual pages describing commands
588 For manual pages that describe a command (typically in Sections 1 and 8),
589 the arguments are always specified using italics,
590 .IR "even in the SYNOPSIS section" .
591 .PP
592 The name of the command, and its options, should
593 always be formatted in bold.
594 .\"
595 .SS Formatting conventions for manual pages describing functions
596 For manual pages that describe functions (typically in Sections 2 and 3),
597 the arguments are always specified using italics,
598 .IR "even in the SYNOPSIS section" ,
599 where the rest of the function is specified in bold:
600 .PP
601 .BI " int myfunction(int " argc ", char **" argv );
602 .PP
603 Variable names should, like argument names, be specified in italics.
604 .PP
605 Any reference to the subject of the current manual page
606 should be written with the name in bold followed by
607 a pair of parentheses in Roman (normal) font.
608 For example, in the
609 .BR fcntl (2)
610 man page, references to the subject of the page would be written as:
611 .BR fcntl ().
612 The preferred way to write this in the source file is:
613 .PP
614 .EX
615 .BR fcntl ()
616 .EE
617 .PP
618 (Using this format, rather than the use of "\efB...\efP()"
619 makes it easier to write tools that parse man page source files.)
620 .\"
621 .SS Use semantic newlines
622 In the source of a manual page,
623 new sentences should be started on new lines,
624 long sentences should be split into lines at clause breaks
625 (commas, semicolons, colons, and so on),
626 and long clauses should be split at phrase boundaries.
627 This convention, sometimes known as "semantic newlines",
628 makes it easier to see the effect of patches,
629 which often operate at the level of
630 individual sentences, clauses, or phrases.
631 .\"
632 .SS Formatting conventions (general)
633 Paragraphs should be separated by suitable markers (usually either
634 .I .PP
635 or
636 .IR .IP ).
637 Do
638 .I not
639 separate paragraphs using blank lines, as this results in poor rendering
640 in some output formats (such as PostScript and PDF).
641 .PP
642 Filenames (whether pathnames, or references to header files)
643 are always in italics (e.g.,
644 .IR <stdio.h> ),
645 except in the SYNOPSIS section, where included files are in bold (e.g.,
646 .BR "#include <stdio.h>" ).
647 When referring to a standard header file include,
648 specify the header file surrounded by angle brackets,
649 in the usual C way (e.g.,
650 .IR <stdio.h> ).
651 .PP
652 Special macros, which are usually in uppercase, are in bold (e.g.,
653 .BR MAXINT ).
654 Exception: don't boldface NULL.
655 .PP
656 When enumerating a list of error codes, the codes are in bold (this list
657 usually uses the
658 .B \&.TP
659 macro).
660 .PP
661 Complete commands should, if long,
662 be written as an indented line on their own,
663 with a blank line before and after the command, for example
664 .PP
665 .in +4n
666 .EX
667 man 7 man\-pages
668 .EE
669 .in
670 .PP
671 If the command is short, then it can be included inline in the text,
672 in italic format, for example,
673 .IR "man 7 man-pages" .
674 In this case, it may be worth using nonbreaking spaces
675 (\e\(ti) at suitable places in the command.
676 Command options should be written in italics (e.g.,
677 .IR \-l ).
678 .PP
679 Expressions, if not written on a separate indented line, should
680 be specified in italics.
681 Again, the use of nonbreaking spaces may be appropriate
682 if the expression is inlined with normal text.
683 .PP
684 When showing example shell sessions, user input should be formatted in bold, for example
685 .PP
686 .in +4n
687 .EX
688 $ \fBdate\fP
689 Thu Jul 7 13:01:27 CEST 2016
690 .EE
691 .in
692 .PP
693 Any reference to another man page
694 should be written with the name in bold,
695 .I always
696 followed by the section number,
697 formatted in Roman (normal) font, without any
698 separating spaces (e.g.,
699 .BR intro (2)).
700 The preferred way to write this in the source file is:
701 .PP
702 .EX
703 .BR intro (2)
704 .EE
705 .PP
706 (Including the section number in cross references lets tools like
707 .BR man2html (1)
708 create properly hyperlinked pages.)
709 .PP
710 Control characters should be written in bold face,
711 with no quotes; for example,
712 .BR \(haX .
713 .SS Spelling
714 Starting with release 2.59,
715 .I man-pages
716 follows American spelling conventions
717 (previously, there was a random mix of British and American spellings);
718 please write all new pages and patches according to these conventions.
719 .PP
720 Aside from the well-known spelling differences,
721 there are a few other subtleties to watch for:
722 .IP * 3
723 American English tends to use the forms "backward", "upward", "toward",
724 and so on
725 rather than the British forms "backwards", "upwards", "towards", and so on.
726 .IP *
727 Opinions are divided on "acknowledgement" vs "acknowledgment".
728 The latter is predominant, but not universal usage in American English.
729 POSIX and the BSD license use the former spelling.
730 In the Linux man-pages project, we use "acknowledgement".
731 .SS BSD version numbers
732 The classical scheme for writing BSD version numbers is
733 .IR x.yBSD ,
734 where
735 .I x.y
736 is the version number (e.g., 4.2BSD).
737 Avoid forms such as
738 .IR "BSD 4.3" .
739 .SS Capitalization
740 In subsection ("SS") headings,
741 capitalize the first word in the heading, but otherwise use lowercase,
742 except where English usage (e.g., proper nouns) or programming
743 language requirements (e.g., identifier names) dictate otherwise.
744 For example:
745 .PP
746 .EX
747 .SS Unicode under Linux
748 .EE
749 .\"
750 .SS Indentation of structure definitions, shell session logs, and so on
751 When structure definitions, shell session logs, and so on are included
752 in running text, indent them by 4 spaces (i.e., a block enclosed by
753 .I ".in\ +4n"
754 and
755 .IR ".in" ),
756 format them using the
757 .I .EX
758 and
759 .I EE
760 macros, and surround them with suitable paragraph markers (either
761 .I .PP
762 or
763 .IR .IP ).
764 For example:
765 .PP
766 .in +4n
767 .EX
768 .PP
769 .in +4n
770 .EX
771 int
772 main(int argc, char *argv[])
773 {
774 return 0;
775 }
776 .EE
777 .in
778 .PP
779 .EE
780 .in
781 .SS Preferred terms
782 The following table lists some preferred terms to use in man pages,
783 mainly to ensure consistency across pages.
784 .ad l
785 .TS
786 l l l
787 ---
788 l l ll.
789 Term Avoid using Notes
790
791 bit mask bitmask
792 built-in builtin
793 Epoch epoch T{
794 For the UNIX Epoch (00:00:00, 1 Jan 1970 UTC)
795 T}
796 filename file name
797 filesystem file system
798 hostname host name
799 inode i-node
800 lowercase lower case, lower-case
801 nonzero non-zero
802 pathname path name
803 pseudoterminal pseudo-terminal
804 privileged port T{
805 reserved port,
806 system port
807 T}
808 real-time T{
809 realtime,
810 real time
811 T}
812 run time runtime
813 saved set-group-ID T{
814 saved group ID,
815 saved set-GID
816 T}
817 saved set-user-ID T{
818 saved user ID,
819 saved set-UID
820 T}
821 set-group-ID set-GID, setgid
822 set-user-ID set-UID, setuid
823 superuser T{
824 super user,
825 super-user
826 T}
827 superblock T{
828 super block,
829 super-block
830 T}
831 timestamp time stamp
832 timezone time zone
833 uppercase upper case, upper-case
834 usable useable
835 user space userspace
836 username user name
837 x86-64 x86_64 T{
838 Except if referring to result of "uname\ \-m" or similar
839 T}
840 zeros zeroes
841 .TE
842 .PP
843 See also the discussion
844 .I Hyphenation of attributive compounds
845 below.
846 .SS Terms to avoid
847 The following table lists some terms to avoid using in man pages,
848 along with some suggested alternatives,
849 mainly to ensure consistency across pages.
850 .ad l
851 .TS
852 l l l
853 ---
854 l l l.
855 Avoid Use instead Notes
856
857 32bit 32-bit T{
858 same for 8-bit, 16-bit, etc.
859 T}
860 current process calling process T{
861 A common mistake made by kernel programmers when writing man pages
862 T}
863 manpage T{
864 man page, manual page
865 T}
866 minus infinity negative infinity
867 non-root unprivileged user
868 non-superuser unprivileged user
869 nonprivileged unprivileged
870 OS operating system
871 plus infinity positive infinity
872 pty pseudoterminal
873 tty terminal
874 Unices UNIX systems
875 Unixes UNIX systems
876 .TE
877 .ad
878 .\"
879 .SS Trademarks
880 Use the correct spelling and case for trademarks.
881 The following is a list of the correct spellings of various
882 relevant trademarks that are sometimes misspelled:
883 .PP
884 DG/UX
885 HP-UX
886 UNIX
887 UnixWare
888 .SS NULL, NUL, null pointer, and null byte
889 A
890 .I null pointer
891 is a pointer that points to nothing,
892 and is normally indicated by the constant
893 .IR NULL .
894 On the other hand,
895 .I NUL
896 is the
897 .IR "null byte" ,
898 a byte with the value 0, represented in C via the character constant
899 .IR \(aq\e0\(aq .
900 .PP
901 The preferred term for the pointer is "null pointer" or simply "NULL";
902 avoid writing "NULL pointer".
903 .PP
904 The preferred term for the byte is "null byte".
905 Avoid writing "NUL", since it is too easily confused with "NULL".
906 Avoid also the terms "zero byte" and "null character".
907 The byte that terminates a C string should be described
908 as "the terminating null byte";
909 strings may be described as "null-terminated",
910 but avoid the use of "NUL-terminated".
911 .SS Hyperlinks
912 For hyperlinks, use the
913 .IR .UR / .UE
914 macro pair
915 (see
916 .BR groff_man (7)).
917 This produces proper hyperlinks that can be used in a web browser,
918 when rendering a page with, say:
919 .PP
920 .in +4n
921 .EX
922 BROWSER=firefox man -H pagename
923 .EE
924 .in
925 .SS Use of e.g., i.e., etc., a.k.a., and similar
926 In general, the use of abbreviations such as "e.g.", "i.e.", "etc.",
927 "cf.", and "a.k.a." should be avoided,
928 in favor of suitable full wordings
929 ("for example", "that is", "and so on", "compare to", "also known as").
930 .PP
931 The only place where such abbreviations may be acceptable is in
932 .I short
933 parenthetical asides (e.g., like this one).
934 .PP
935 Always include periods in such abbreviations, as shown here.
936 In addition, "e.g." and "i.e." should always be followed by a comma.
937 .SS Em-dashes
938 The way to write an em-dash\(emthe glyph that appears
939 at either end of this subphrase\(emin *roff is with the macro "\e(em".
940 (On an ASCII terminal, an em-dash typically renders as two hyphens,
941 but in other typographical contexts it renders as a long dash.)
942 Em-dashes should be written
943 .I without
944 surrounding spaces.
945 .SS Hyphenation of attributive compounds
946 Compound terms should be hyphenated when used attributively
947 (i.e., to qualify a following noun). Some examples:
948 .PP
949 32-bit value
950 command-line argument
951 floating-point number
952 run-time check
953 user-space function
954 wide-character string
955 .SS Hyphenation with multi, non, pre, re, sub, and so on
956 The general tendency in modern English is not to hyphenate
957 after prefixes such as "multi", "non", "pre", "re", "sub", and so on.
958 Manual pages should generally follow this rule when these prefixes are
959 used in natural English constructions with simple suffixes.
960 The following list gives some examples of the preferred forms:
961 .PP
962 interprocess
963 multithreaded
964 multiprocess
965 nonblocking
966 nondefault
967 nonempty
968 noninteractive
969 nonnegative
970 nonportable
971 nonzero
972 preallocated
973 precreate
974 prerecorded
975 reestablished
976 reinitialize
977 rearm
978 reread
979 subcomponent
980 subdirectory
981 subsystem
982 .PP
983 Hyphens should be retained when the prefixes are used in nonstandard
984 English words, with trademarks, proper nouns, acronyms, or compound terms.
985 Some examples:
986 .PP
987 non-ASCII
988 non-English
989 non-NULL
990 non-real-time
991 .PP
992 Finally, note that "re-create" and "recreate" are two different verbs,
993 and the former is probably what you want.
994 .\"
995 .SS Generating optimal glyphs
996 Where a real minus character is required (e.g., for numbers such as \-1,
997 for man page cross references such as
998 .BR utf\-8 (7),
999 or when writing options that have a leading dash, such as in
1000 .IR "ls\ \-l"),
1001 use the following form in the man page source:
1002 .PP
1003 .in +4n
1004 .EX
1005 \e\-
1006 .EE
1007 .in
1008 .PP
1009 This guideline applies also to code examples.
1010 .PP
1011 The use of real minus signs serves the following purposes:
1012 .\" https://lore.kernel.org/linux-man/20210121061158.5ul7226fgbrmodbt@localhost.localdomain/
1013 .IP * 3
1014 To provide better renderings on various targets other than
1015 ASCII terminals,
1016 notably in PDF and on Unicode/UTF\-8-capable terminals.
1017 .IP *
1018 To generate glyphs that when copied from rendered pages will
1019 produce real minus signs when pasted into a terminal.
1020 .PP
1021 To produce unslanted single quotes that render well in ASCII, UTF-8, and PDF,
1022 use "\e(aq" ("apostrophe quote"); for example
1023 .PP
1024 .in +4n
1025 .EX
1026 \e(aqC\e(aq
1027 .EE
1028 .in
1029 .PP
1030 where
1031 .I C
1032 is the quoted character.
1033 This guideline applies also to character constants used in code examples.
1034 .PP
1035 Where a proper caret (\(ha) that renders well in both a terminal and PDF
1036 is required, use "\\(ha".
1037 This is especially necessary in code samples,
1038 to get a nicely rendered caret when rendering to PDF.
1039 .PP
1040 Using a naked "\(ti" character results in a poor rendering in PDF.
1041 Instead use "\\(ti".
1042 This is especially necessary in code samples,
1043 to get a nicely rendered tilde when rendering to PDF.
1044 .\"
1045 .SS Example programs and shell sessions
1046 Manual pages may include example programs demonstrating how to
1047 use a system call or library function.
1048 However, note the following:
1049 .IP * 3
1050 Example programs should be written in C.
1051 .IP *
1052 An example program is necessary and useful only if it demonstrates
1053 something beyond what can easily be provided in a textual
1054 description of the interface.
1055 An example program that does nothing
1056 other than call an interface usually serves little purpose.
1057 .IP *
1058 Example programs should ideally be short
1059 (e.g., a good example can often be provided in less than 100 lines of code),
1060 though in some cases longer programs may be necessary
1061 to properly illustrate the use of an API.
1062 .IP *
1063 Expressive code is appreciated.
1064 .IP *
1065 Comments should included where helpful.
1066 Complete sentences in free-standing comments should be
1067 terminated by a period.
1068 Periods should generally be omitted in "tag" comments
1069 (i.e., comments that are placed on the same line of code);
1070 such comments are in any case typically brief phrases
1071 rather than complete sentences.
1072 .IP *
1073 Example programs should do error checking after system calls and
1074 library function calls.
1075 .IP *
1076 Example programs should be complete, and compile without
1077 warnings when compiled with \fIcc\ \-Wall\fP.
1078 .IP *
1079 Where possible and appropriate, example programs should allow
1080 experimentation, by varying their behavior based on inputs
1081 (ideally from command-line arguments, or alternatively, via
1082 input read by the program).
1083 .IP *
1084 Example programs should be laid out according to Kernighan and
1085 Ritchie style, with 4-space indents.
1086 (Avoid the use of TAB characters in source code!)
1087 The following command can be used to format your source code to
1088 something close to the preferred style:
1089 .IP
1090 .in +4n
1091 .EX
1092 indent \-npro \-kr \-i4 \-ts4 \-sob \-l72 \-ss \-nut \-psl prog.c
1093 .EE
1094 .in
1095 .IP *
1096 For consistency, all example programs should terminate using either of:
1097 .IP
1098 .in +4n
1099 .EX
1100 exit(EXIT_SUCCESS);
1101 exit(EXIT_FAILURE);
1102 .EE
1103 .in
1104 .IP
1105 Avoid using the following forms to terminate a program:
1106 .IP
1107 .in +4n
1108 .EX
1109 exit(0);
1110 exit(1);
1111 return n;
1112 .EE
1113 .in
1114 .IP *
1115 If there is extensive explanatory text before the
1116 program source code, mark off the source code
1117 with a subsection heading
1118 .IR "Program source" ,
1119 as in:
1120 .IP
1121 .SS Program source
1122 .IP
1123 Always do this if the explanatory text includes a shell session log.
1124 .PP
1125 If you include a shell session log demonstrating the use of a program
1126 or other system feature:
1127 .IP * 3
1128 Place the session log above the source code listing
1129 .IP *
1130 Indent the session log by four spaces.
1131 .IP *
1132 Boldface the user input text,
1133 to distinguish it from output produced by the system.
1134 .PP
1135 For some examples of what example programs should look like, see
1136 .BR wait (2)
1137 and
1138 .BR pipe (2).
1139 .SH EXAMPLES
1140 For canonical examples of how man pages in the
1141 .I man-pages
1142 package should look, see
1143 .BR pipe (2)
1144 and
1145 .BR fcntl (2).
1146 .SH SEE ALSO
1147 .BR man (1),
1148 .BR man2html (1),
1149 .BR attributes (7),
1150 .BR groff (7),
1151 .BR groff_man (7),
1152 .BR man (7),
1153 .BR mdoc (7)