From 8be02157b3657344bfd51b19b7f802f5787e4020 Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Fri, 23 Oct 2026 13:58:50 +0100 Subject: [PATCH] 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 --- diff --git a/PROPOSALS.md b/PROPOSALS.md index 0e9dd76..b487023 100644 --- a/PROPOSALS.md +++ b/PROPOSALS.md @@ -2968,6 +2968,7 @@ ### Freestanding programs and tools -- `Doc` fills a list — rcrypto's paragraphs read as well, and a line - indented further already means code, which a list's continuation - would muddle. +- `Doc` fills a list. Done (owner, 2026-10-23), by lazy continuation: a + line starting with `- ` at a comment's margin begins a bullet, the + lines at the margin after it continue it, and a blank line or code + ends it, so an indented line is still code. diff --git a/test/doc/Bullets.expect b/test/doc/Bullets.expect new file mode 100644 index 0000000..4b62555 --- /dev/null +++ b/test/doc/Bullets.expect @@ -0,0 +1,14 @@ +module Bullets; + Bullets: a comment's list. + Doc's test of it. + +proc f*; + What it takes: + - a first item; + - a second item that runs on + to a second line at the margin; + - a third. + + Text after the list, with a dash - in the middle. + code after + - a dash that is further in, so code diff --git a/test/doc/Bullets.man b/test/doc/Bullets.man new file mode 100644 index 0000000..367f8c0 --- /dev/null +++ b/test/doc/Bullets.man @@ -0,0 +1,29 @@ +.Ss Bullets +.Bd -literal +module Bullets; +.Ed +.Bd -filled -offset indent -compact +Bullets: a comment's list. +Doc's test of it. +.Ed +.Bd -literal +proc f*; +.Ed +.Bd -filled -offset indent -compact +What it takes: +.Bl -bullet -compact +.It +a first item; +.It +a second item that runs on +to a second line at the margin; +.It +a third. +.El +.Pp +Text after the list, with a dash - in the middle. +.Ed +.Bd -literal -offset indent -compact +code after +- a dash that is further in, so code +.Ed diff --git a/test/doc/Bullets.raz b/test/doc/Bullets.raz new file mode 100644 index 0000000..ff5ed33 --- /dev/null +++ b/test/doc/Bullets.raz @@ -0,0 +1,18 @@ +(* Bullets: a comment's list. + Doc's test of it. *) +module Bullets; + +(* What it takes: + - a first item; + - a second item that runs on + to a second line at the margin; + - a third. + + Text after the list, with a dash - in the middle. + code after + - a dash that is further in, so code *) +proc f*; +begin +end; + +end Bullets. diff --git a/tools/Doc.raz b/tools/Doc.raz index 20fdfb0..f4f894f 100644 --- a/tools/Doc.raz +++ b/tools/Doc.raz @@ -9,7 +9,8 @@ prints the same of each module, in mdoc, for a library's manual page: the module's name a heading, each declaration a literal display, each comment filled text, indented, but for its lines indented - further, which are code. It writes the modules only; the page's + further, which are code; a line of the text that starts with "- " + begins a list's bullet (see comment). It writes the modules only; the page's head (its date, name and description, up to .Sh MODULES) and tail are files of the library's own, put around it by its Makefile. @@ -33,6 +34,7 @@ man: BOOL; (* writing mdoc *) atStart: BOOL; (* emit is at the start of a line *) shown: BOOL; (* a literal display of mdoc's is open *) + listed: BOOL; (* a bullet list of mdoc's is open *) groupStart, groupEnd: INT; (* the comment that heads the group being read, not yet written, or -1 *) (* On to the next symbol that isn't a comment, keeping where the last @@ -73,6 +75,13 @@ atStart := true; end; +(* the bullet list, if open, closed *) +proc closeList; +begin + if listed then control(".El"); end; + listed := false; +end; + (* the literal display, if open, closed *) proc close; begin @@ -167,7 +176,10 @@ 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. *) + filled one ends where the code starts and starts again after. A line + that starts with "- " at the text's own margin starts a bullet of a + list; the lines at the margin after it continue it, and a blank line + or code ends it. *) proc comment(start, stop: INT); var i, j, k, m, n, deep, indent: INT; begin @@ -185,6 +197,7 @@ n := 0; while (i + n < k) and (src[i + n] = ' ') do INC(n); end; if man and (n > deep) and (indent < 0) then + closeList; control(".Ed"); control(".Bd -literal -offset indent -compact"); indent := n; @@ -193,9 +206,17 @@ control(".Bd -filled -offset indent -compact"); indent := -1; end; - if man and (n = k - i) and (indent < 0) then control(".Pp"); + if man and (n = k - i) and (indent < 0) then + closeList; + control(".Pp"); elsif man and (indent < 0) then m := i + n; + if (m + 1 < k) and (src[m] = '-') and (src[m + 1] = ' ') then + if not listed then control(".Bl -bullet -compact"); listed := true; end; + control(".It"); + INC(m, 2); + while (m < k) and (src[m] = ' ') do INC(m); end; + end; while m < k do if (src[m] = ' ') and sentenceEnds(i + n, m) then emit(10); @@ -214,7 +235,7 @@ end; i := k + 1; end; - if man then control(".Ed"); end; + if man then closeList; control(".Ed"); end; end; (* The comment that heads a group of constants, types or variables,