r/linuxquestions • u/mcsuper5 • Oct 20 '26
Manpages for multiple commands
Any recommendations for learning how to use the various macros for formatting? Ideally I'd be looking for something compatible across multiple OSes (Linux, NetBSD, OSX, and Haiku).
I written a couple of smaller pages by hacking small manpages but don't understand the formatting.
I also need to learn how the man system knows to find multiple commands in one page (man -w strncpy -> /usr/share/man/man3/strcpy.3.gz). I've written several small tools, primarily for working with acme, that I'd like to keep together in one page.
2
Upvotes
2
u/aioeu Oct 20 '26 edited Oct 20 '26
There's a couple of roff macro packages for man pages. Take a look at
groff_man(+groff_man_style) andgroff_mdoc. I would probably go with the former as it's older and probably more widely supported, but at least on Linux you can generally use either:manis usually set up to automatically detect which one you've used via themandocpackage — this switches its behaviour on whether you've used.THor.Ddat the top of your document.2
u/stevevdvkpe Oct 20 '26
UNIX man pages are formatted using the
trofftypesetting formatter (the "roff" part is short for "runoff", an earlier formatter that originated the convention of embedding formatting commands in text starting with a '.' at the beginning of a line). Man pages are designed to be capable of producing both nicely typeset output or output suitable for reading with a fixed-width font on a terminal or in line printer output using a variant callednroff. Specifically a macro package "man" or "mandoc" is used to help generate the conventional man page formatting (the standard sections like "NAME", "SYNOPSIS", "DESCRIPTION", etc.; paragraphs and margins, and so on). On most Linux systems the GNUgroffpackage replaces the traditionaltroff/nroffprograms.When a man page documents mulitple functions, generally there are symbolic links from the alternate function names to the base copy of the man page. In the case of
strncpy(), there is a symbolic link:/usr/share/man/man3/strncpy.3.gz -> stpncpy.3.gzand the man page source in
stpcpy.3.gzdocuments bothstrncpy()andstpncpy().2
u/calrogman Oct 20 '26
1
u/Away_Combination6977 Oct 20 '26
I have read over this post 5 times... And I still have zero idea what you're asking.
And, I'll admit, I probably don't want to. 😂
1
u/MilkThin2930 Oct 20 '26
man manshould explain the macros. makewhatis or man-db look for a series of comma-separated names in the NAME section of a man page when building the index.1
u/Typical-Employment41 Oct 20 '26
Doesn't it make it much harder to find (with / shortcut) what different flags do for one command? How about using terminal multiplexer, like screen or tmux, to view them side by side?
1
u/SensoredHacker Oct 20 '26
troff.
I can always spot a manpage made properly,
Kudos, for investigating how to do it proper.