问题
I'm trying to write some specifications to be shared between a small team and getting picky about the format I put some command listings in. Is there any formal definition of the syntax used in the SYNOPSIS section of man pages?
From the Wikimedia Commons, here's an example of a man page with the SYNOPSIS section I'm talking about, where the command is listed with the required and optional arguments it understands.
回答1:
There is no formal definition of a manpage anywhere, not even in the POSIX standard. The man(1)
manpage in your example is pretty typical: you write out the various ways a program can be used (often just one) with []
denoting optional, bold (or typewriter font with the mdoc macros) denoting literal command line input and italics denoting variables.
The manpages man(7)
and mdoc(7)
will explain the most important conventions. man(7)
is for old-style Unix manpages and is still popular on Linux (see man-pages(7)
); mdoc(7)
comes from 4.4BSD and is popular in its derivatives. The latter maintains a stricter separation of content and presentation and can produce (IMHO) prettier PDF/HTML output
回答2:
man 7 man-pages:
briefly describes the command or function's interface. For commands, this shows the syntax of the command and its arguments (including options); boldface is used for as-is text and italics are used to indicate replaceable arguments. Brackets ([]) surround optional arguments, vertical bars (|) separate choices, and ellipses (...) can be repeated. For functions, it shows any required data declarations or #include directives, followed by the function declaration.
回答3:
The utility conventions for utilities are documented in in Chapter 12. Utility conventions of the IEEE Std 1003.1, 2004 Edition.
A newer edition of this document exists here
来源:https://stackoverflow.com/questions/8716047/is-there-a-specification-for-a-man-pages-synopsis-section