Home Home > 2010 > 02 > 07 > Writing man pages
Sign up | Login

Writing man pages

February 7th, 2010 by

Here are a few resources for those among you thinking of writing proper documentation for your new project, or to contribute writings or translations to your favorite Community.

Man pages are written in Troff, the original UNIX typesetting system. Nowadays, few people (most notably man page writers and IETF RFC authors) regularly use this markup, but it is rather simple and elegant once you get to know it. For writing man pages, the learning curve is very good, as you only need to know a few macros and, just as if you were working on html and pilfering the sources of an existing  page doing just what you need, you have a wealth of examples to teach you right there on your trusty *NIX box. As the Wikipedia points out:

Troff features commands to designate fonts, spacing, paragraphs, margins, footnotes and more. Unlike many other text formatters, troff can position characters arbitrarily on a page, even overlapping them, and has a fully programmable input language. Separate preprocessors are used for more convenient production of tables, diagrams, and mathematics.

But you don’t need to master all that! For man pages, what you need is knowledge of the man macro package, originally written by James Clark and documented in man(7) or groff_man(7) depending on your distro. Troff input is processed from text files, so you just need your favorite text editor, and a bit of time to play with the markup to learn it in the process.

Here is a way to get started quickly: Linux Journal published a great tutorial a few years back, and the Linux Manual contains the ever-important style guidelines in man-pages(7). Start from scratch, or make a copy of an existing manual page and start editing. One more tip for you:

man ./foo.1

is your friend, to see what you just wrote and marked up in all its glory — and bugs.

WEB RESOURCES
Linux Journal: Writing man Pages Using groff
The Linux Manual:
man-pages(7)
The Linux Manual:
man(7)

BOOKS
Arnold Robbins, Nelson Beebe, Classic Shell Scripting (O’Reilly – 9780596005955) – Appendix A “Writing Man Pages” is for you.
Dale Dougherty, Tim O’Reilly, Unix Text Processing (out of print, released in the public domain) – all the Troff you could ever want, but not the man macros.

Both comments and pings are currently closed.

One Response to “Writing man pages”

  1. I recently came across your blog and have been reading along. I thought I would leave my first comment. I don’t know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.

    Lucy