raz / commit 8be02157

commit
8be02157b3657344bfd51b19b7f802f5787e4020
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
0938de09
Doc: a line starting with - at a comment's margin begins a bullet of a list, the margin's lines after it continue it, a blank line or code ends it; mdoc .Bl -bullet; test/doc/Bullets

patch · log

5 files changed, +90 -7

PROPOSALS.md modified +4 -3

@@ -2968,6 +2968,7 @@
29682968 ### Freestanding programs and tools
29692969
29702970
2971-- `Doc` fills a list — rcrypto's paragraphs read as well, and a line
2972- indented further already means code, which a list's continuation
2973- would muddle.
2971+- `Doc` fills a list. Done (owner, 2026-10-23), by lazy continuation: a
2972+ line starting with `- ` at a comment's margin begins a bullet, the
2973+ lines at the margin after it continue it, and a blank line or code
2974+ ends it, so an indented line is still code.

test/doc/Bullets.expect (history) added +14 -0

@@ -0,0 +1,14 @@
1+module Bullets;
2+ Bullets: a comment's list.
3+ Doc's test of it.
4+
5+proc f*;
6+ What it takes:
7+ - a first item;
8+ - a second item that runs on
9+ to a second line at the margin;
10+ - a third.
11+
12+ Text after the list, with a dash - in the middle.
13+ code after
14+ - a dash that is further in, so code

test/doc/Bullets.man (history) added +29 -0

@@ -0,0 +1,29 @@
1+.Ss Bullets
2+.Bd -literal
3+module Bullets;
4+.Ed
5+.Bd -filled -offset indent -compact
6+Bullets: a comment's list.
7+Doc's test of it.
8+.Ed
9+.Bd -literal
10+proc f*;
11+.Ed
12+.Bd -filled -offset indent -compact
13+What it takes:
14+.Bl -bullet -compact
15+.It
16+a first item;
17+.It
18+a second item that runs on
19+to a second line at the margin;
20+.It
21+a third.
22+.El
23+.Pp
24+Text after the list, with a dash - in the middle.
25+.Ed
26+.Bd -literal -offset indent -compact
27+code after
28+- a dash that is further in, so code
29+.Ed

test/doc/Bullets.raz (history) added +18 -0

@@ -0,0 +1,18 @@
1+(* Bullets: a comment's list.
2+ Doc's test of it. *)
3+module Bullets;
4+
5+(* What it takes:
6+ - a first item;
7+ - a second item that runs on
8+ to a second line at the margin;
9+ - a third.
10+
11+ Text after the list, with a dash - in the middle.
12+ code after
13+ - a dash that is further in, so code *)
14+proc f*;
15+begin
16+end;
17+
18+end Bullets.

tools/Doc.raz (history) modified +25 -4

@@ -9,7 +9,8 @@
99 prints the same of each module, in mdoc, for a library's manual page:
1010 the module's name a heading, each declaration a literal display,
1111 each comment filled text, indented, but for its lines indented
12- further, which are code. It writes the modules only; the page's
12+ further, which are code; a line of the text that starts with "- "
13+ begins a list's bullet (see comment). It writes the modules only; the page's
1314 head (its date, name and description, up to .Sh MODULES) and tail
1415 are files of the library's own, put around it by its Makefile.
1516
@@ -33,6 +34,7 @@
3334 man: BOOL; (* writing mdoc *)
3435 atStart: BOOL; (* emit is at the start of a line *)
3536 shown: BOOL; (* a literal display of mdoc's is open *)
37+ listed: BOOL; (* a bullet list of mdoc's is open *)
3638 groupStart, groupEnd: INT; (* the comment that heads the group being read, not yet written, or -1 *)
3739
3840 (* On to the next symbol that isn't a comment, keeping where the last
@@ -73,6 +75,13 @@
7375 atStart := true;
7476 end;
7577
78+(* the bullet list, if open, closed *)
79+proc closeList;
80+begin
81+ if listed then control(".El"); end;
82+ listed := false;
83+end;
84+
7685 (* the literal display, if open, closed *)
7786 proc close;
7887 begin
@@ -167,7 +176,10 @@
167176 indented by four; in mdoc, filled, each sentence starting a line,
168177 but for the lines indented past its own, which are code, kept as
169178 they are in a literal display. mdoc's displays don't nest, so the
170- filled one ends where the code starts and starts again after. *)
179+ filled one ends where the code starts and starts again after. A line
180+ that starts with "- " at the text's own margin starts a bullet of a
181+ list; the lines at the margin after it continue it, and a blank line
182+ or code ends it. *)
171183 proc comment(start, stop: INT);
172184 var i, j, k, m, n, deep, indent: INT;
173185 begin
@@ -185,6 +197,7 @@
185197 n := 0;
186198 while (i + n < k) and (src[i + n] = ' ') do INC(n); end;
187199 if man and (n > deep) and (indent < 0) then
200+ closeList;
188201 control(".Ed");
189202 control(".Bd -literal -offset indent -compact");
190203 indent := n;
@@ -193,9 +206,17 @@
193206 control(".Bd -filled -offset indent -compact");
194207 indent := -1;
195208 end;
196- if man and (n = k - i) and (indent < 0) then control(".Pp");
209+ if man and (n = k - i) and (indent < 0) then
210+ closeList;
211+ control(".Pp");
197212 elsif man and (indent < 0) then
198213 m := i + n;
214+ if (m + 1 < k) and (src[m] = '-') and (src[m + 1] = ' ') then
215+ if not listed then control(".Bl -bullet -compact"); listed := true; end;
216+ control(".It");
217+ INC(m, 2);
218+ while (m < k) and (src[m] = ' ') do INC(m); end;
219+ end;
199220 while m < k do
200221 if (src[m] = ' ') and sentenceEnds(i + n, m) then
201222 emit(10);
@@ -214,7 +235,7 @@
214235 end;
215236 i := k + 1;
216237 end;
217- if man then control(".Ed"); end;
238+ if man then closeList; control(".Ed"); end;
218239 end;
219240
220241 (* The comment that heads a group of constants, types or variables,