public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] makedocbook: Fix false report of unhandled texinfo command
@ 2022-10-31  9:59 Jon Turney
  2022-10-31 12:28 ` Mike Frysinger
  0 siblings, 1 reply; 4+ messages in thread
From: Jon Turney @ 2022-10-31  9:59 UTC (permalink / raw)
  To: newlib; +Cc: Jon Turney

During 'make man', makedocbook falsely reports "texinfo command
'@modifier' remains in output" while processing the setlocal(3) manpage,
which contains that literal string.

Move the check for unrecognized texinfo commands to before processing
'@@' (an escaped '@') in the texinfo source, and teach it to ignore
them.

Improve that check slightly, so it catches non-alphabetic texinfo
commands, of which there are few.

Now we don't have false positives, we can make unrecognized texinfo
commands fatal to manpage generation, rather than leaving them verbatim
in the generated manpage.
---
 newlib/doc/makedocbook.py | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/newlib/doc/makedocbook.py b/newlib/doc/makedocbook.py
index 4e83ab63a..00b3fc140 100755
--- a/newlib/doc/makedocbook.py
+++ b/newlib/doc/makedocbook.py
@@ -454,9 +454,6 @@ command_dispatch_dict = {
 def line_markup_convert(p):
     s = p;
 
-    # process the texinfo escape for an @
-    s = s.replace('@@', '@')
-
     # escape characters not allowed in XML
     s = s.replace('&','&')
     s = s.replace('<','&lt;')
@@ -486,6 +483,15 @@ def line_markup_convert(p):
     # very hacky way of dealing with @* to force a newline
     s = s.replace('@*', '</para><para>')
 
+    # fail if there are unhandled texinfo commands
+    match = re.search('(?<!@)@[^@\s]+', s)
+    if match:
+        print("texinfo command '%s' remains in output" % match.group(), file=sys.stderr)
+        exit(1)
+
+    # process the texinfo escape for an @
+    s = s.replace('@@', '@')
+
     if (verbose > 3) and (s != p):
         print('%s-> line_markup_convert ->\n%s' % (p, s), file=sys.stderr)
 
@@ -827,10 +833,6 @@ def main(file):
 
     print(s)
 
-    # warn about texinfo commands which didn't get processed
-    match = re.search('@[a-z*]+', s)
-    if match:
-        print('texinfo command %s remains in output' % match.group(), file=sys.stderr)
 
 #
 #
-- 
2.38.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-11-04 15:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-31  9:59 [PATCH] makedocbook: Fix false report of unhandled texinfo command Jon Turney
2022-10-31 12:28 ` Mike Frysinger
2022-11-04 13:50   ` Jon Turney
2022-11-04 15:13     ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).