From 88e8e9b09f4407b806a46df9c635c074eccc0fd5 Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Thu, 15 Oct 2026 06:43:29 +0000 Subject: [PATCH] Manual pages that mandoc reads without a warning Doc writes each sentence of a comment on a line of its own, and ends the filled display around code rather than nesting one in it; the pages' empty .Cm, .Pp before .Bl and .Xr order mended; raz-lib(3) dated October 14, when Str last changed. --- diff --git a/doc/raz-tutorial.7 b/doc/raz-tutorial.7 index ff75b02..59bab52 100644 --- a/doc/raz-tutorial.7 +++ b/doc/raz-tutorial.7 @@ -61,7 +61,7 @@ .Cm main of the module named on the command line. Every statement ends in -.Cm ";" , +.Cm \&; , even one that ends in .Cm end . .Sh 2. MODULES @@ -1051,8 +1051,8 @@ at zero, and no two integer types mix in an expression. .Sh SEE ALSO .Xr raz 1 , -.Xr raz 7 , -.Xr raz-lib 3 ; +.Xr raz-lib 3 , +.Xr raz 7 ; the report, .Pa doc/raz.md , in raz's sources. diff --git a/doc/raz.7 b/doc/raz.7 index 32db81e..6747069 100644 --- a/doc/raz.7 +++ b/doc/raz.7 @@ -120,7 +120,7 @@ .Ed .Pp Every statement ends in -.Cm ";" , +.Cm \&; , even one that ends in .Cm end or @@ -188,7 +188,6 @@ .It "(a, b, c)" Ta "1" Ta "an enumeration, 256 names at most" .It "set of E" Ta "1, 2, 4, 8" Ta "bit i for E's name i, 64 at most" .El -.Pp .Bl -bullet .It A @@ -267,7 +266,6 @@ .It "and" Ta "evaluates its right side only if needed" .It "or" Ta "the same" .El -.Pp .Bl -bullet .It Both operands have one type, or one is an untyped constant that fits diff --git a/tools/Doc.raz b/tools/Doc.raz index 4e556a4..384fade 100644 --- a/tools/Doc.raz +++ b/tools/Doc.raz @@ -19,7 +19,7 @@ module Doc; import Out, Rt, Str, Buf, Heap, Scan, Files; -const Date = "October 12, 2026"; (* raz-lib(3)'s, when the library last changed *) +const Date = "October 14, 2026"; (* raz-lib(3)'s, when the library last changed *) var sc: Scan.Scanner; (* the text being read, at the current symbol *) @@ -144,9 +144,24 @@ emit(10); end; +(* Whether the space at src[p] ends a sentence: a full stop, ? or ! + comes before it, maybe behind closing brackets or quotes. mdoc wants + each sentence on a line of its own, so that roff knows where one + ends and spaces it so. *) +proc sentenceEnds(start, p: INT): BOOL; +begin + DEC(p); + while (p > start) and ((src[p] = ')') or (src[p] = ']') or (src[p] = '"') or (src[p] = '\'')) do + DEC(p); + end; + return (p >= start) and ((src[p] = '.') or (src[p] = '?') or (src[p] = '!')); +end; + (* The comment from start to stop, without its brackets, each line - indented by four; in mdoc, filled, but for the lines indented past - its own, which are code, kept as they are. *) + indented by four; in mdoc, filled, each sentence starting a line, + but for the lines indented past its own, which are code, kept as + they are in a literal display. mdoc's displays don't nest, so the + filled one ends where the code starts and starts again after. *) proc comment(start, stop: INT); var i, j, k, m, n, deep, indent: INT; begin @@ -164,23 +179,35 @@ n := 0; while (i + n < k) and (src[i + n] = ' ') do INC(n); end; if man and (n > deep) and (indent < 0) then + control(".Ed"); control(".Bd -literal -offset indent -compact"); indent := n; elsif man and (n <= deep) and (indent >= 0) then control(".Ed"); + control(".Bd -filled -offset indent -compact"); indent := -1; end; if man and (n = k - i) and (indent < 0) then control(".Pp"); + elsif man and (indent < 0) then + m := i + n; + while m < k do + if (src[m] = ' ') and sentenceEnds(i + n, m) then + emit(10); + while (m + 1 < k) and (src[m + 1] = ' ') do INC(m); end; + else emit(src[m]); + end; + INC(m); + end; + emit(10); else if not man then Out.str(" "); - elsif (indent >= 0) and (n > indent) then n := indent; + elsif n > indent then n := indent; end; for m := i + n to k - 1 do emit(src[m]); end; emit(10); end; i := k + 1; end; - if indent >= 0 then control(".Ed"); end; if man then control(".Ed"); end; end;