To be kind to 'whatis' database generators; move MACRO_DEF
out of the NAME section.
Every man page created by Perl Pod::Man has macro defs above
the .TH header. There are over 5000 of them on my system. So
it doesn't seem to be a problem to have them in the head.
I am still unsure, please be patient with me
man 7 man says:
pod2man ignores this obviously, the whatis might be a perl program to begin with :-)
this seams important too
I am testing still
lexgrog checking in sandbox/manpage-writer/expected
OK
expected/docinfo-deu-l_de.man: "deutsches_manpage_beispiel - manpage beschreibung"
expected/docinfo-deu-l_en.man: "deutsches_manpage_beispiel - manpage beschreibung"
expected/docinfo-deu.man: "deutsches_manpage_beispiel - manpage beschreibung"
expected/docinfo-eng-l_de.man: "english_manpage_sample - manpage description"
expected/docinfo-eng-l_en.man: "english_manpage_sample - manpage description"
expected/docinfo-eng.man: "english_manpage_sample - manpage description"
expected/man-de.1.man: "man - Programm zum Einsehen der Online-Manuale"
expected/optionslisttest.man: "OptionlistTest - Test for correct intention/detention of optionlists"
expected/test.man: "rst2man - generate unix manpages from reStructured text"
FAIL
expected/characters.man: parse failed
expected/compact_lists.man: parse failed
expected/dotted.man: parse failed
expected/indent.man: parse failed
expected/optionstoo.man: parse failed
but these fail because .SH NAME
names with blanks are not allowed in
empty descriptions are not allowed
could you send me your (minimal) document please
On Mon, 23 Mar 2020, engelbert gruber wrote:
Well, not exactly. IMO, Man(7) is written for a beginner man page author, and
the line you quote is intentionally over simplified.
Man pages are roff source files. In roff there is no such thing as a 'command'.
In roff terminology there are 'requests' and 'macros':
That line is referring to macros, specifically 'an macros'. So, the first
man macro called must be TH. There is no problem calling roff requests before
the TH macro. Custom macros should be included before the document, just as
they would when included with the roff -m<tmac> option.</tmac>
I have an idea the reason the docutils macro definitions where originally added
in the NAME section is do to a misunderstanding of this comment:
But that must be understood in the context it was written. It is referring to
the author redefining any of the GNU 'extension' an-ext.tmac man page macros,
which are included after the TH macro is processed. Meaning, if the author
tries to redefine them before the TH, they will get clobbered. I cannot imagine
why anyone would want to redefine a GNU an-ext.tmac macro, and manpage.py is
certainly not doing that.
It looks like you are testing with lexgrog and trying to reproduce a failure.
That's fine, but there are at least 3 whatis parsers that I know of. I maintain
one of them. The macro defs did not cause a hard-fail for me, they just put
garbage in the index. So I cannot send you a manpage.py document that will
hard-fail lexgrog (if that is what you are asking for).
I have patched my parser to handle what manpage.py does, but it is still the
wrong location to be adding custom roff macro definitions. Polluting the
document space not only makes things harder for whatis parsers (and believe me
that is difficult enough with all the junk authors put in the NAME section),
but it also makes it harder for maintainers to review the source file.
I hope you will consider applying the patch and seeing if the results cause any
new failures for you. I'm confident that they will not.
Thank you Engelbert,
Willie
sorry for the horrendous delay
Hi there. I work on groff upstream. The reason for advising the definition of page-local versions of man(7) extension macros after the
TH
call is indeed to keep them from being clobbered when andoc.tmac (re-)sources the an.tmac file.People might redefine a GNU an-ext.tmac macro to ensure the portability of their page to an environment that doesn't support the GNU extensions they use. For example, in 2009, the groff man extension macros
MT
,ME
,UR
,UE
,SY
,YS
, andTQ
were fairly new. Over time, other implementations, like Heirloom Doctools troff and mandoc(1), adopted them.In July of this year, we released groff 1.23.0, which has a new man(7) macro,
MR
(pioneered by Plan 9 from User Space troff), for setting hyperlinkable man page cross references. groff 1.23.0's own man pages define a fallback version ofMR
(much less complex than the "official" one) so that the arguments to the macro can still be read as text in the page even if the page is formatted by an implementation that doesn't supportMR
, like groff 1.22.4 or earlier. (Normally, calls to undefined macros are discarded by the formatter along with their arguments.)Here's an example. https://git.savannah.gnu.org/cgit/groff.git/tree/src/preproc/eqn/neqn.1.man?h=1.23.0
In the foregoing,
MR
is defined only if it isn't already; the fallback definition is used only if groff 1.23.0 isn't the formatter. It would indeed be harmless to put this definition before theTH
call, and let it get clobbered, but (1) there still seemed to be a notional risk of feeblemakewhatis
implementations getting confused by such content at that location, and (2) I wanted to keep the advice to man page authors simple. Page-local macros should be defined only if necessary, and I didn't want to burden the groff_man(7) page with an exploration of the varying consequences of defining them (a) before theTH
call; (b) afterTH
but before.SH Name
; (c) after presenting the page's summary description with.SH Name
; or (d) even later than that.Let me know if I can further illuminate this issue.
Regards,
Branden
Last edit: G. Branden Robinson 2023-10-07