0

If I want to write man pages which are portable between different Unix-like systems, which source language standard should I use? Or can I simply assume that GNU troff (groff) is available everywhere?

August Karlstrom
  • 10,773
  • 7
  • 38
  • 60
  • troff is typically available in a unix-y install that expects to display manpages. – pvg Apr 26 '17 at 20:47
  • 1
    @pvg Still, it's not clear which features in groff that are portable. GNU software tends to add anything that might be useful to someone. – August Karlstrom Apr 26 '17 at 21:01
  • 1
    I think manpages use a fairly constrained subset and the fact that some unixes use groff (Linux, OS X) is incidental. OpenBSD seems to have written their own formatter a few years ago because, well, OpenBSD. But I think the sanest thing is to use one of the many higher-level systems that know how to spit out manpages. They seem to generate portable-enough manpages. – pvg Apr 26 '17 at 21:16

1 Answers1

0

If you look at https://www.troff.org/macros.html, under man, it lists two guides for writing man pages.

In general, they both recommend avoiding using additional preprocessors such as tbl, pic, or eqn especially if you want to maximize portability.

Man pages use the an macro package. This was done so when you called it with the -m macro option it shows as troff -man. To find the macros defined by the an macro package, you should look for files matching either tmac.an* (for UNIX/BSD systems) or an*.tmac (for Linux systems). For example, on RHEL/CentOS it would be:

/usr/share/groff/1.18.1.4/tmac/an.tmac which refers to
/usr/share/groff/1.18.1.4/tmac/andoc.tmac which refers to
/usr/share/groff/1.18.1.4/tmac/an-old.tmac which defines most of the macros

These files are part of the groff package.

tk421
  • 5,775
  • 6
  • 23
  • 34