gbranden pushed a commit to branch master
in repository groff.

commit 4368a976e4a1f8c97949a5a445d61afb3639165b
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Sep 24 19:43:04 2026 -0500

    [mdoc]: Import warning diagnostic from man(7).
    
    Import groff man(7)'s "you forgot to run tbl" diagnostic.
    
    * tmac/doc.tmac (TE): New macro throws warning diagnostic if `TW`
      register is not defined, and marks warning as thrown.
    * tmac/mdoc/doc-common (Dd): At document initialization, delete `TW`
      register and reset "warning thrown" state.
    
    Illustration:
    
    $ cat ATTIC/do-not-preprocess.mdoc
    .Dd 2026-09-24
    .Dt foo 1
    .Os "groff test suite"
    .Sh Name
    .Nm foo
    .Nd frobnicate a bar
    .Sh Description
    Here is a table,
    but I will forget to use
    .Ic tbl
    to preprocess it.
    .TS
    L.
    baz
    .TE
    $ ./build/test-groff -r LL=72n -m andoc -T utf8 ATTIC/do-not-preprocess.mdoc
    doc.tmac:ATTIC/do-not-preprocess.mdoc:15: warning: tbl preprocessor failed, 
or it or soelim was not run; table(s) likely not rendered (TE macro called with 
TW register undefined)
    foo(1)                   General Commands Manual                  foo(1)
    
    Name
         foo —— frobnicate a bar
    
    Description
         Here is a table, but I will forget to use tbl to preprocess it.
         L.  baz
    
    groff test suite               2026‐09‐24                         foo(1)
---
 ChangeLog            | 10 ++++++++++
 tmac/doc.tmac        | 14 ++++++++++++++
 tmac/mdoc/doc-common |  4 ++++
 3 files changed, 28 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 6e2608bd7..8d4798351 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2026-09-24  G. Branden Robinson <[email protected]>
+
+       [mdoc]: Import groff man(7)'s "you forgot to run tbl"
+       diagnostic.
+
+       * tmac/doc.tmac (TE): New macro throws warning diagnostic if
+       `TW` register is not defined, and marks warning as thrown.
+       * tmac/mdoc/doc-common (Dd): At document initialization, delete
+       `TW` register and reset "warning thrown" state.
+
 2026-09-27  G. Branden Robinson <[email protected]>
 
        Unsplit groff's Info manual.
diff --git a/tmac/doc.tmac b/tmac/doc.tmac
index fc742d3ce..7802c79b6 100644
--- a/tmac/doc.tmac
+++ b/tmac/doc.tmac
@@ -7150,6 +7150,20 @@ arguments
 ..
 .
 .
+.eo
+.de TE
+.  if !r TW .if !\n[doc-was-tbl-failure-reported] \{\
+.    ds doc-msg tbl preprocessor failed, or it or soelim was not run;\"
+.    as doc-msg " table(s) likely not rendered\"
+.    as doc-msg " (TE macro called with TW register undefined)\"
+.    doc-warn \*[doc-msg]
+.    rm doc-msg
+.    nr doc-was-tbl-failure-reported 1
+.  \}
+..
+.ec
+.
+.
 .\" NS doc-defunct-macro macro
 .\" NS   this is the skeleton for defunct macros
 .\" NS
diff --git a/tmac/mdoc/doc-common b/tmac/mdoc/doc-common
index e98619dc3..2535cf376 100644
--- a/tmac/mdoc/doc-common
+++ b/tmac/mdoc/doc-common
@@ -306,6 +306,10 @@
 .  \}
 .  if \n[C] .rr P
 .
+.  \" We've seen no tbl(1) tables yet in this document.
+.  rr TW
+.  nr doc-was-tbl-failure-reported 0
+.
 .  \" When rendering multiple documents, we want to clear any page-local
 .  \" manipulation of hyphenation and adjustment modes from the previous
 .  \" document.

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to