raz / commit 88e8e9b0

commit
88e8e9b09f4407b806a46df9c635c074eccc0fd5
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
972ed02a
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.

patch · log

3 files changed, +36 -11

doc/raz-tutorial.7 (history) modified +3 -3

@@ -61,7 +61,7 @@
6161 .Cm main
6262 of the module named on the command line.
6363 Every statement ends in
64-.Cm ";" ,
64+.Cm \&; ,
6565 even one that ends in
6666 .Cm end .
6767 .Sh 2. MODULES
@@ -1051,8 +1051,8 @@
10511051 at zero, and no two integer types mix in an expression.
10521052 .Sh SEE ALSO
10531053 .Xr raz 1 ,
1054-.Xr raz 7 ,
1055-.Xr raz-lib 3 ;
1054+.Xr raz-lib 3 ,
1055+.Xr raz 7 ;
10561056 the report,
10571057 .Pa doc/raz.md ,
10581058 in raz's sources.

doc/raz.7 (history) modified +1 -3

@@ -120,7 +120,7 @@
120120 .Ed
121121 .Pp
122122 Every statement ends in
123-.Cm ";" ,
123+.Cm \&; ,
124124 even one that ends in
125125 .Cm end
126126 or
@@ -188,7 +188,6 @@
188188 .It "(a, b, c)" Ta "1" Ta "an enumeration, 256 names at most"
189189 .It "set of E" Ta "1, 2, 4, 8" Ta "bit i for E's name i, 64 at most"
190190 .El
191-.Pp
192191 .Bl -bullet
193192 .It
194193 A
@@ -267,7 +266,6 @@
267266 .It "and" Ta "evaluates its right side only if needed"
268267 .It "or" Ta "the same"
269268 .El
270-.Pp
271269 .Bl -bullet
272270 .It
273271 Both operands have one type, or one is an untyped constant that fits

tools/Doc.raz (history) modified +32 -5

@@ -19,7 +19,7 @@
1919 module Doc;
2020 import Out, Rt, Str, Buf, Heap, Scan, Files;
2121
22-const Date = "October 12, 2026"; (* raz-lib(3)'s, when the library last changed *)
22+const Date = "October 14, 2026"; (* raz-lib(3)'s, when the library last changed *)
2323
2424 var
2525 sc: Scan.Scanner; (* the text being read, at the current symbol *)
@@ -144,9 +144,24 @@
144144 emit(10);
145145 end;
146146
147+(* Whether the space at src[p] ends a sentence: a full stop, ? or !
148+ comes before it, maybe behind closing brackets or quotes. mdoc wants
149+ each sentence on a line of its own, so that roff knows where one
150+ ends and spaces it so. *)
151+proc sentenceEnds(start, p: INT): BOOL;
152+begin
153+ DEC(p);
154+ while (p > start) and ((src[p] = ')') or (src[p] = ']') or (src[p] = '"') or (src[p] = '\'')) do
155+ DEC(p);
156+ end;
157+ return (p >= start) and ((src[p] = '.') or (src[p] = '?') or (src[p] = '!'));
158+end;
159+
147160 (* The comment from start to stop, without its brackets, each line
148- indented by four; in mdoc, filled, but for the lines indented past
149- its own, which are code, kept as they are. *)
161+ indented by four; in mdoc, filled, each sentence starting a line,
162+ but for the lines indented past its own, which are code, kept as
163+ they are in a literal display. mdoc's displays don't nest, so the
164+ filled one ends where the code starts and starts again after. *)
150165 proc comment(start, stop: INT);
151166 var i, j, k, m, n, deep, indent: INT;
152167 begin
@@ -164,23 +179,35 @@
164179 n := 0;
165180 while (i + n < k) and (src[i + n] = ' ') do INC(n); end;
166181 if man and (n > deep) and (indent < 0) then
182+ control(".Ed");
167183 control(".Bd -literal -offset indent -compact");
168184 indent := n;
169185 elsif man and (n <= deep) and (indent >= 0) then
170186 control(".Ed");
187+ control(".Bd -filled -offset indent -compact");
171188 indent := -1;
172189 end;
173190 if man and (n = k - i) and (indent < 0) then control(".Pp");
191+ elsif man and (indent < 0) then
192+ m := i + n;
193+ while m < k do
194+ if (src[m] = ' ') and sentenceEnds(i + n, m) then
195+ emit(10);
196+ while (m + 1 < k) and (src[m + 1] = ' ') do INC(m); end;
197+ else emit(src[m]);
198+ end;
199+ INC(m);
200+ end;
201+ emit(10);
174202 else
175203 if not man then Out.str(" ");
176- elsif (indent >= 0) and (n > indent) then n := indent;
204+ elsif n > indent then n := indent;
177205 end;
178206 for m := i + n to k - 1 do emit(src[m]); end;
179207 emit(10);
180208 end;
181209 i := k + 1;
182210 end;
183- if indent >= 0 then control(".Ed"); end;
184211 if man then control(".Ed"); end;
185212 end;
186213