This tries to be the documentation on how to write man-pages for the GNUstep project. If you adhere to this standard all GNUstep related man-pages will have an identical structure, which makes them easier to read.
If you installed GNUstep in the default /usr/GNUstep directory you should add to /etc/manpath.config the following entries:
MANDATORY_MANPATH /usr/GNUstep/System/Library/Documentation/man MANDATORY_MANPATH /usr/GNUstep/Local/Library/Documentation/man MANPATH_MAP /usr/GNUstep/System/Tools /usr/GNUstep/System/Library/Documentation/man MANPATH_MAP /usr/GNUstep/Local/Tools /usr/GNUstep/Local/Library/Documentation/man MANDB_MAP /usr/GNUstep/System/Library/Documentation/man /var/cache/man MANDB_MAP /usr/GNUstep/Local/Library/Documentation/man /var/cache/man
Then you have to rebuild the mandb with:
/usr/bin/mandb --no-purge
To make sure the man-pages can be used on as much platforms as possible, they should be tested. The tools that should be available for testing are:
groff -man -Tascii gpbs.1
groff -man -Tps ./page.1 > page.psto make sure the conversion to PostScript is correct.
rman -fHTML ./page.1 > page.htmland make sure the HTML page is viewable in a couple of browsers (lynx, Mozilla firefox) and that there are are no serious problems reported by the rman command.
lexgrog ./page.1to check it the whatis data is filtered out correctly.
Man-pages are stored in a structured fashion below the man/ directory, which are called chapters. The man/ directory contains 9 chapters named man1 to man9. These directories contain the actual man-pages, where the unzipped postfix is the number of the section the man-page belongs to. openapp.1 is thus stored in man/man1/
Below follows a description of the different chapters:
1 | Executable programs or shell commands |
2 | System calls (functions provided by the kernel) |
3 | Library calls (functions within program libraries) |
4 | Special files (usually found in /dev) |
5 | File formats and conventions eg /etc/passwd |
6 | Games |
7 | Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7) |
8 | System administration commands (usually only for root) |
9 | Kernel routines [Non standard] |
Man-pages are devided in sections. There are several sections that can be used and you can name them as you like, however to stay consistent with other manual pages (and make it easier on the reader) it is best to stick with some common named sections.
The first section has to be NAME since this is the one used by whatis and apropos. All other sections are not defined, but if you compare existing man-pages there seems to be an unwritten law of the order. This chapter is devided in sections that represent the order of appearence in a man-page.
For those entirely new to writing man-pages there is a list of all the macros that can be used in man-pages and their function at the end of this document.
It is good practice to start off the page with some remarks that describe how the page should be rendered. Such a section could look like this:
.\" Process this file with .\" groff -man -Tascii openapp.1
The .\" macro is the start of a remark. The information provided to the next end of line will not appear in the man-page, but is only used as meta-information.
Bold |
The subject of the man-page Environment variables options to commands and functions |
Italics |
arguments to options files directories |
A required section
The name in the .TH macro is in caps used for the command. Meaning if the command is in small caps the name is. This is to be able to also document commands and functions with alternating caps.
.TH openapp 1 "08/12/2007" gnustep-gui "GNUstep System Manual"can be opened with:
man ./openapp.1and outputs:
openapp(1) GNUstep System Manual openapp(1) gnustep-gui 08/12/2007 openapp(1)
A required section
The first section in the man-page is the NAME section. This section has a standardized format consisting of a comma-separated list of program or function names, followed by a dash, followed by a short (usually one line) description of the functionality the program (or function, or file) is supposed to provide. By means of mandb(8), the name sections make it into the whatis database files. mandb is the reason the name section must exist, and why it must adhere to the format described.
.SH NAME foo \- foo descriptionThe \- is of importance here. The backslash is needed to make the dash distinct from a hyphenation dash that may appear in either the command name or the one line description.
.SH NAME openapp \- Command line tool for starting applicationsis formatted as:
NAME openapp - Command line tool for starting applications
To test that you didn't make a mistake and that whatis is able to parse the information correctly do the following:
lexgrog ./openapp.1 ./openapp.1: "openapp - Command line tool for starting applications"
A required section for functions and programs
The synopsis gives a short overview on the syntaxis of a program or function. For functions this sections lists corresponding include files and the prototype so the programmer knows the type and number of arguments as well as the return type.
Example:
.SH SYNOPSIS .B openapp .RB [ --find ] .RB [ --debug " [" --gdb=\fI...\fR ]] .RB [ --library-combo=\fI...\fR ] .I application .RI [ arguments... ]Looks like:
SYNOPSIS openapp [ --find ] [--debug [--gdb=...]] [--library-combo=...] application [arguments...]
A required section
An as complete description as possible. This section should spell out what the program or function does. Without the need of going into details about the different options.
A required section for functions, programs and configuration files
It is based around a list of .TP macros. Where the option is set in bold and the description in a normal font.
Example:
.SH OPTIONS .TP .BI --find " application" will print out the full path of the application executable which would be executed, without actually executing it. It will also list all paths that are attempted.Is rendered as:
OPTIONS --find application will print out the full path of the application executable which would be executed, without actually executing it. It will also list all paths that are attempted.
A required section for functions and programs
Optional
A required section for functions and programs
A required section for shell scripts
An optional section
Lists all the files used by the program or function. For example, log files, configuration files, and startup files. It is often best to use the full path name to the file.
An optional section
Bugs in the program or function known to the author of the man-page should be mentioned here.
A required section
A list of related man pages in alphabetical order.
A required section
This section describes the project, program or function history.
A required section
Mentions the names and e-mail addresses of the authors that worked on the man-page, so they can be contacted about errors, omissions or to send compliments.
The person who started the page should be mentioned on top, with every later editor below that one in chronological order, so the last person who editer the page is listed at the bottom.
An optional section
Thank you's and the like go in the section.
Required section
Copyright statement concerning the man-page, all GNUstep man-pages should comply with the GNU man-page copyrights:
.SH COPYRIGHT Copyright (C) YEAR Free Software Foundation, Inc. .PP Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved.
The default font is Roman, 10 points.
Do not use structures like \fB \fR within your man-pages, but only use the below mentioned macro's.
This manual page for .B openapp describes its functionWhich is rendered as:
This manual page for openapp describes its function
The log file .I syslog logs system logsWhich is rendered as:
The log file syslog logs system logs
.BR this " is a " testWhich is rendered as:
this is a test
.RB this " is a " testWhich is rendered as:
this is a test
.IR this " is a " test"Which is rendered as:
this is a test
.RI this " is a " test"Which is rendered as:
this is a test
.BI this " is a " test"Which is rendered as:
this is a test
.BI this " is a " test"Which is rendered as:
this is a test
.SM ASCII
.TH [name of program] [section number] [center footer] [left footer] [center header]As you can see there is only a small part defined the rest is only header and footer information. For GNUstep we use the following convention:
.IP \(bu item1 .IP \(bu item2When using man the bullets will not be shown, there will only be a idnented list.
.TP .BI --debug " application" starts the application in the debugger. By default gdb, but this can be changed with the --gdb= argument or through the GDB shell variable.Which is rendered as:
--debug application starts the application in the debugger. By default gdb, but this can be changed with the --gdb= argument or through the GDB shell variable.
.PP .RS 0 foo bar '{ .RS 0 Name = "My Application"; .RS 0 Author = "Just me and \"my other half\""; .RS 0 Modules = ( .RS 0 Main, .RS 0 "''Input output''", .RS 0 Computation .RS 0 ); .RS 0 Checksum = <01014b5b 123a8b20> .RS 0 }'Which is then rendered as:
foo bar '{ Name = "My Application"; Author = "Just me and \"my other half\""; Modules = ( Main, "''Input output''", Computation ); Checksum = <01014b5b 123a8b20> }'