| | @@ -9,7 +9,8 @@ |
| 9 | 9 | prints the same of each module, in mdoc, for a library's manual page: |
| 10 | 10 | the module's name a heading, each declaration a literal display, |
| 11 | 11 | 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 |
| 13 | 14 | head (its date, name and description, up to .Sh MODULES) and tail |
| 14 | 15 | are files of the library's own, put around it by its Makefile. |
| 15 | 16 | |
| | @@ -33,6 +34,7 @@ |
| 33 | 34 | man: BOOL; (* writing mdoc *) |
| 34 | 35 | atStart: BOOL; (* emit is at the start of a line *) |
| 35 | 36 | shown: BOOL; (* a literal display of mdoc's is open *) |
| 37 | + listed: BOOL; (* a bullet list of mdoc's is open *) |
| 36 | 38 | groupStart, groupEnd: INT; (* the comment that heads the group being read, not yet written, or -1 *) |
| 37 | 39 | |
| 38 | 40 | (* On to the next symbol that isn't a comment, keeping where the last |
| | @@ -73,6 +75,13 @@ |
| 73 | 75 | atStart := true; |
| 74 | 76 | end; |
| 75 | 77 | |
| 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 | + |
| 76 | 85 | (* the literal display, if open, closed *) |
| 77 | 86 | proc close; |
| 78 | 87 | begin |
| | @@ -167,7 +176,10 @@ |
| 167 | 176 | indented by four; in mdoc, filled, each sentence starting a line, |
| 168 | 177 | but for the lines indented past its own, which are code, kept as |
| 169 | 178 | 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. *) |
| 171 | 183 | proc comment(start, stop: INT); |
| 172 | 184 | var i, j, k, m, n, deep, indent: INT; |
| 173 | 185 | begin |
| | @@ -185,6 +197,7 @@ |
| 185 | 197 | n := 0; |
| 186 | 198 | while (i + n < k) and (src[i + n] = ' ') do INC(n); end; |
| 187 | 199 | if man and (n > deep) and (indent < 0) then |
| 200 | + closeList; |
| 188 | 201 | control(".Ed"); |
| 189 | 202 | control(".Bd -literal -offset indent -compact"); |
| 190 | 203 | indent := n; |
| | @@ -193,9 +206,17 @@ |
| 193 | 206 | control(".Bd -filled -offset indent -compact"); |
| 194 | 207 | indent := -1; |
| 195 | 208 | 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"); |
| 197 | 212 | elsif man and (indent < 0) then |
| 198 | 213 | 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; |
| 199 | 220 | while m < k do |
| 200 | 221 | if (src[m] = ' ') and sentenceEnds(i + n, m) then |
| 201 | 222 | emit(10); |
| | @@ -214,7 +235,7 @@ |
| 214 | 235 | end; |
| 215 | 236 | i := k + 1; |
| 216 | 237 | end; |
| 217 | | - if man then control(".Ed"); end; |
| 238 | + if man then closeList; control(".Ed"); end; |
| 218 | 239 | end; |
| 219 | 240 | |
| 220 | 241 | (* The comment that heads a group of constants, types or variables, |