raz-lib(3), the library, made from its sources Doc man writes mdoc: each module under a heading of its name, its own comment, then each exported declaration with its comment, those with none sharing a display; a comment's lines indented past its own are code. make man builds build/raz-lib.3 from lib/, in the report's order, and make check lints it. Library comments that ran past 80 columns on the page are shorter, or split.
| @@ -32,7 +32,7 @@ | ||
| 32 | 32 | rm -rf build raz |
| 33 | 33 | |
| 34 | 34 | # every example and test, against what it should print |
| 35 | -check: raz | |
| 35 | +check: raz build/raz-lib.3 | |
| 36 | 36 | test/check.sh |
| 37 | 37 | |
| 38 | 38 | # line numbers: gdb stops at a line and names it |
| @@ -74,6 +74,17 @@ | ||
| 74 | 74 | @rloc -f src/*.pas |
| 75 | 75 | @rloc -c src/*.pas |
| 76 | 76 | |
| 77 | +# raz-lib(3), the library's manual page, made by tools/Doc.raz from | |
| 78 | +# its sources, in the order of the report's section 11 | |
| 79 | +LIBDOC = Rt Mem Heap Arena Lock Thread.linux-x86_64 Out Sys.linux-x86_64 \ | |
| 80 | + Str Buf Fmt List Map Sort Math Files Opt C | |
| 81 | + | |
| 82 | +man: build/raz-lib.3 | |
| 83 | + | |
| 84 | +build/raz-lib.3: raz tools/Doc.raz tools/Scan.raz lib/*.raz | build | |
| 85 | + ./raz -Werror -o build/Doc tools/Doc.raz | |
| 86 | + build/Doc man $(LIBDOC:%=lib/%.raz) > $@ | |
| 87 | + | |
| 77 | 88 | # the report as a PDF, by pandoc and Chromium; not part of check, as |
| 78 | 89 | # CI has neither |
| 79 | 90 | pdf: build/raz.pdf |
| @@ -99,4 +110,4 @@ | ||
| 99 | 110 | uninstall: |
| 100 | 111 | rm -rf $(PREFIX)/lib/raz $(PREFIX)/bin/raz $(PREFIX)/share/man/man1/raz.1 |
| 101 | 112 | |
| 102 | -.PHONY: units tests check gdb bench stress fmt loc pdf clean install uninstall | |
| 113 | +.PHONY: units tests check gdb bench stress fmt loc man pdf clean install uninstall |
| @@ -34,7 +34,7 @@ | ||
| 34 | 34 | Pascal and C to raz", a table of what each spells differently, as |
| 35 | 35 | concha's tour has from sh. About 500 lines. The examples go in |
| 36 | 36 | `test/man`, run by `make check`. |
| 37 | -2. **`raz-lib(3)`, the library, made from its sources.** `tools/Doc` | |
| 37 | +2. Done: **`raz-lib(3)`, the library, made from its sources.** `tools/Doc` | |
| 38 | 38 | learns to write mdoc: each module's own comment, then its exported |
| 39 | 39 | declarations with theirs, under a heading of its name. `make` builds |
| 40 | 40 | the page from `lib/`, so it says what the library says, always. |
| @@ -13,9 +13,10 @@ | ||
| 13 | 13 | extern proc isatty*(fd: I32): I32; |
| 14 | 14 | extern proc exit*(status: I32); |
| 15 | 15 | extern proc _exit*(status: I32); |
| 16 | -extern proc __errno_location*: ^I32; (* errno is this thread's: through here *) | |
| 16 | +extern proc __errno_location*: ^I32; (* errno, this thread's *) | |
| 17 | 17 | extern proc sched_yield*: I32; |
| 18 | -extern proc pthread_create*(t: ^UINT; attr: ^U8; start: proc(arg: ^U8): ^U8; arg: ^U8): I32; | |
| 18 | +extern proc pthread_create*(t: ^UINT; attr: ^U8; | |
| 19 | + start: proc(arg: ^U8): ^U8; arg: ^U8): I32; | |
| 19 | 20 | extern proc pthread_join*(t: UINT; result: ^^U8): I32; |
| 20 | 21 | extern proc rename*(old, new: ^U8): I32; |
| 21 | 22 | extern proc unlink*(path: ^U8): I32; |
| @@ -5,7 +5,7 @@ | ||
| 5 | 5 | |
| 6 | 6 | type |
| 7 | 7 | Allocator* = record |
| 8 | - alloc*: proc(a: ^Allocator; size, align: INT): ^U8; (* nil if out of room *) | |
| 8 | + alloc*: proc(a: ^Allocator; size, align: INT): ^U8; (* or nil *) | |
| 9 | 9 | free*: proc(a: ^Allocator; p: ^U8); |
| 10 | 10 | end; |
| 11 | 11 |
| @@ -13,7 +13,7 @@ | ||
| 13 | 13 | |
| 14 | 14 | type |
| 15 | 15 | Row* = variant |
| 16 | - usage(scope, line: []U8); (* a synopsis line, without "usage: " *) | |
| 16 | + usage(scope, line: []U8); (* a synopsis, without "usage: " *) | |
| 17 | 17 | sub(scope, name, help: []U8); (* a subcommand *) |
| 18 | 18 | option(scope: []U8; letter: U8; long, value, help: []U8); |
| 19 | 19 | end; |
| @@ -27,7 +27,7 @@ | ||
| 27 | 27 | scope: []U8; |
| 28 | 28 | at: INT; (* the next word *) |
| 29 | 29 | group: []U8; (* the letters left of a word of them, as -lw *) |
| 30 | - spelt: []U8; (* the option just read as written, without its dashes *) | |
| 30 | + spelt: []U8; (* the option just read, as written, no dashes *) | |
| 31 | 31 | ended: BOOL; (* the scope's options have ended *) |
| 32 | 32 | help: BOOL; (* the option just read is -h or --help *) |
| 33 | 33 | end; |
| @@ -22,7 +22,7 @@ | ||
| 22 | 22 | import Sys; |
| 23 | 23 | |
| 24 | 24 | const |
| 25 | - Full*: ERROR = "too many procedures to run at exit"; (* from atExit *) | |
| 25 | + Full*: ERROR = "too many procedures to run at exit"; (* atExit's *) | |
| 26 | 26 | MaxAtExit = 32; |
| 27 | 27 | SigFpe = 8; |
| 28 | 28 | SigSegv = 11; |
| @@ -17,16 +17,17 @@ | ||
| 17 | 17 | type |
| 18 | 18 | (* What open is asked for: reading, writing or both, and what else |
| 19 | 19 | it does to the file. *) |
| 20 | - Access* = (reading, writing, creating, exclusive, truncating, appending); | |
| 20 | + Access* = (reading, writing, creating, exclusive, truncating, | |
| 21 | + appending); | |
| 21 | 22 | Accesses* = set of Access; (* what open is given *) |
| 22 | 23 | |
| 23 | 24 | (* What info says of a file. *) |
| 24 | 25 | Info* = record |
| 25 | 26 | size*: I64; (* in bytes *) |
| 26 | - mtime*: I64; (* when its contents last changed, in nanoseconds since 1970 *) | |
| 27 | + mtime*: I64; (* its contents' last change, in ns since 1970 *) | |
| 27 | 28 | mode*: INT; (* its permission bits, rwxrwxrwx *) |
| 28 | 29 | dir*: BOOL; (* a directory *) |
| 29 | - file*: BOOL; (* a regular file: not a directory, device, pipe or socket *) | |
| 30 | + file*: BOOL; (* not a directory, device, pipe or socket *) | |
| 30 | 31 | symlink*: BOOL; (* the path itself is a symbolic link *) |
| 31 | 32 | end; |
| 32 | 33 | |
| @@ -40,13 +41,13 @@ | ||
| 40 | 41 | Program* = record |
| 41 | 42 | path*: []U8; |
| 42 | 43 | args*: [][]U8; (* the first is its name *) |
| 43 | - env*: [][]U8; (* NAME=value, each added to this program's environment *) | |
| 44 | + env*: [][]U8; (* NAME=value, each added to this environment *) | |
| 44 | 45 | onlyEnv*: BOOL; (* env is its whole environment *) |
| 45 | 46 | dir*: []U8; (* its working directory; "" for this program's *) |
| 46 | - fds*: [3]INT; (* its standard input, output and error; 0 for this program's own *) | |
| 47 | - group*: INT; (* the process group it joins: 0 for this program's, -1 a new one it leads *) | |
| 48 | - foreground*: BOOL; (* its group takes the terminal on standard input *) | |
| 49 | - tty*: INT; (* a pseudo-terminal's fd, to start a session on; 0 for none *) | |
| 47 | + fds*: [3]INT; (* stdin, stdout, stderr; 0 for this program's *) | |
| 48 | + group*: INT; (* its group: 0 for this program's, -1 a new one *) | |
| 49 | + foreground*: BOOL; (* its group gets the terminal on standard input *) | |
| 50 | + tty*: INT; (* a pseudo-terminal to start a session on, or 0 *) | |
| 50 | 51 | end; |
| 51 | 52 | (* How a program that wait waited for changed. *) |
| 52 | 53 | Status* = (running, exited, killed, stopped); |
| @@ -30,16 +30,17 @@ | ||
| 30 | 30 | type |
| 31 | 31 | (* What open is asked for: reading, writing or both, and what else |
| 32 | 32 | it does to the file. *) |
| 33 | - Access* = (reading, writing, creating, exclusive, truncating, appending); | |
| 33 | + Access* = (reading, writing, creating, exclusive, truncating, | |
| 34 | + appending); | |
| 34 | 35 | Accesses* = set of Access; (* what open is given *) |
| 35 | 36 | |
| 36 | 37 | (* What info says of a file. *) |
| 37 | 38 | Info* = record |
| 38 | 39 | size*: I64; (* in bytes *) |
| 39 | - mtime*: I64; (* when its contents last changed, in nanoseconds since 1970 *) | |
| 40 | + mtime*: I64; (* its contents' last change, in ns since 1970 *) | |
| 40 | 41 | mode*: INT; (* its permission bits, rwxrwxrwx *) |
| 41 | 42 | dir*: BOOL; (* a directory *) |
| 42 | - file*: BOOL; (* a regular file: not a directory, device, pipe or socket *) | |
| 43 | + file*: BOOL; (* not a directory, device, pipe or socket *) | |
| 43 | 44 | symlink*: BOOL; (* the path itself is a symbolic link *) |
| 44 | 45 | end; |
| 45 | 46 | |
| @@ -52,13 +53,13 @@ | ||
| 52 | 53 | Program* = record |
| 53 | 54 | path*: []U8; |
| 54 | 55 | args*: [][]U8; (* the first is its name *) |
| 55 | - env*: [][]U8; (* NAME=value, each added to this program's environment *) | |
| 56 | + env*: [][]U8; (* NAME=value, each added to this environment *) | |
| 56 | 57 | onlyEnv*: BOOL; (* env is its whole environment *) |
| 57 | 58 | dir*: []U8; (* its working directory; "" for this program's *) |
| 58 | - fds*: [3]INT; (* its standard input, output and error; 0 for this program's own *) | |
| 59 | - group*: INT; (* the process group it joins: 0 for this program's, -1 a new one it leads *) | |
| 60 | - foreground*: BOOL; (* its group takes the terminal on standard input *) | |
| 61 | - tty*: INT; (* a pseudo-terminal's fd, to start a session on; 0 for none *) | |
| 59 | + fds*: [3]INT; (* stdin, stdout, stderr; 0 for this program's *) | |
| 60 | + group*: INT; (* its group: 0 for this program's, -1 a new one *) | |
| 61 | + foreground*: BOOL; (* its group gets the terminal on standard input *) | |
| 62 | + tty*: INT; (* a pseudo-terminal to start a session on, or 0 *) | |
| 62 | 63 | end; |
| 63 | 64 | (* How a program that wait waited for changed. *) |
| 64 | 65 | Status* = (running, exited, killed, stopped); |
| @@ -98,9 +98,9 @@ | ||
| 98 | 98 | $raz -o $out/Busy test/list/Busy.raz |
| 99 | 99 | if RAZ_PROFILE=1 $out/Busy 2>&1 >/dev/null | sed -n 2p | grep -q 'Busy.spin$'; then pass=$((pass + 1)) |
| 100 | 100 | else echo "FAIL RAZ_PROFILE: Busy.spin isn't first"; fail=$((fail + 1)); fi |
| 101 | -# the manual pages, which groff and mandoc, where there, must read | |
| 102 | -# without a warning | |
| 103 | -for f in doc/*.[1-9]; do | |
| 101 | +# the manual pages, raz-lib(3) as make made it from lib/, which groff | |
| 102 | +# and mandoc, where there, must read without a warning | |
| 103 | +for f in doc/*.[1-9] build/raz-lib.3; do | |
| 104 | 104 | : > $out/man.out |
| 105 | 105 | command -v groff > /dev/null && groff -mdoc -ww -z $f >> $out/man.out 2>&1 |
| 106 | 106 | command -v mandoc > /dev/null && mandoc -Tlint -Wwarning $f >> $out/man.out 2>&1 |
| @@ -11,7 +11,7 @@ | ||
| 11 | 11 | that keeps -h for itself, and completion for concha. |
| 12 | 12 | |
| 13 | 13 | type Row* = variant |
| 14 | - usage(scope, line: []U8); (* a synopsis line, without "usage: " *) | |
| 14 | + usage(scope, line: []U8); (* a synopsis, without "usage: " *) | |
| 15 | 15 | sub(scope, name, help: []U8); (* a subcommand *) |
| 16 | 16 | option(scope: []U8; letter: U8; long, value, help: []U8); |
| 17 | 17 | end; |
| @@ -26,7 +26,7 @@ | ||
| 26 | 26 | scope: []U8; |
| 27 | 27 | at: INT; (* the next word *) |
| 28 | 28 | group: []U8; (* the letters left of a word of them, as -lw *) |
| 29 | - spelt: []U8; (* the option just read as written, without its dashes *) | |
| 29 | + spelt: []U8; (* the option just read, as written, no dashes *) | |
| 30 | 30 | ended: BOOL; (* the scope's options have ended *) |
| 31 | 31 | help: BOOL; (* the option just read is -h or --help *) |
| 32 | 32 | end; |
| @@ -5,6 +5,12 @@ | ||
| 5 | 5 | each exported declaration as it is written, with the comment just |
| 6 | 6 | before it. |
| 7 | 7 | |
| 8 | + Doc man Module.raz ... | |
| 9 | + prints the same of each module, as the manual page raz-lib(3), in | |
| 10 | + mdoc: the module's name a heading, each declaration a literal | |
| 11 | + display, each comment filled text, indented, but for its lines | |
| 12 | + indented further, which are code. | |
| 13 | + | |
| 8 | 14 | Doc examples report.md dir |
| 9 | 15 | Doc examples page.7 dir |
| 10 | 16 | writes each example of the report, or of a manual page, that is a |
| @@ -12,11 +18,16 @@ | ||
| 12 | 18 | dir/Name.raz, and prints the names, one a line. *) |
| 13 | 19 | module Doc; |
| 14 | 20 | import Out, Rt, Str, Buf, Heap, Scan, Files; |
| 21 | + | |
| 22 | +const Date = "October 12, 2026"; (* raz-lib(3)'s, when the library last changed *) | |
| 15 | 23 | |
| 16 | 24 | var |
| 17 | 25 | sc: Scan.Scanner; (* the text being read, at the current symbol *) |
| 18 | 26 | src: []U8; |
| 19 | 27 | docStart, docEnd: INT; (* the comment just before it, or -1 *) |
| 28 | + man: BOOL; (* writing mdoc *) | |
| 29 | + atStart: BOOL; (* emit is at the start of a line *) | |
| 30 | + shown: BOOL; (* a literal display of mdoc's is open *) | |
| 20 | 31 | |
| 21 | 32 | (* On to the next symbol that isn't a comment, keeping where the last |
| 22 | 33 | comment that starts a line was: one after code on its line belongs |
| @@ -35,6 +46,34 @@ | ||
| 35 | 46 | until sc.kind # Scan.comment; |
| 36 | 47 | end; |
| 37 | 48 | |
| 49 | +(* c, written out; in mdoc, so that roff takes it as text: a backslash | |
| 50 | + is \e, and a line that would start with . or ' is a control line | |
| 51 | + unless \& comes first. *) | |
| 52 | +proc emit(c: U8); | |
| 53 | +begin | |
| 54 | + if man and (c = '\\') then Out.str("\\e"); | |
| 55 | + else | |
| 56 | + if man and atStart and ((c = '.') or (c = '\'')) then Out.str("\\&"); end; | |
| 57 | + Out.char(c); | |
| 58 | + end; | |
| 59 | + atStart := c = 10; | |
| 60 | +end; | |
| 61 | + | |
| 62 | +(* a line of mdoc's own, such as .Ed *) | |
| 63 | +proc control(s: []U8); | |
| 64 | +begin | |
| 65 | + Out.str(s); | |
| 66 | + Out.ln; | |
| 67 | + atStart := true; | |
| 68 | +end; | |
| 69 | + | |
| 70 | +(* the literal display, if open, closed *) | |
| 71 | +proc close; | |
| 72 | +begin | |
| 73 | + if shown then control(".Ed"); end; | |
| 74 | + shown := false; | |
| 75 | +end; | |
| 76 | + | |
| 38 | 77 | proc text: []U8; |
| 39 | 78 | begin |
| 40 | 79 | return Scan.text(ADR(sc)); |
| @@ -95,46 +134,69 @@ | ||
| 95 | 134 | col := start - lineStart(start); |
| 96 | 135 | i := start; |
| 97 | 136 | while i < stop do |
| 98 | - Out.char(src[i]); | |
| 137 | + emit(src[i]); | |
| 99 | 138 | if src[i] = 10 then |
| 100 | 139 | n := 0; |
| 101 | 140 | while (n < col) and (i + 1 < stop) and (src[i + 1] = ' ') do INC(i); INC(n); end; |
| 102 | 141 | end; |
| 103 | 142 | INC(i); |
| 104 | 143 | end; |
| 105 | - Out.ln; | |
| 144 | + emit(10); | |
| 106 | 145 | end; |
| 107 | 146 | |
| 108 | 147 | (* The comment from start to stop, without its brackets, each line |
| 109 | - indented by four. *) | |
| 148 | + indented by four; in mdoc, filled, but for the lines indented past | |
| 149 | + its own, which are code, kept as they are. *) | |
| 110 | 150 | proc comment(start, stop: INT); |
| 111 | -var i, j: INT; atLine: BOOL; | |
| 151 | +var i, j, k, m, n, deep, indent: INT; | |
| 112 | 152 | begin |
| 113 | 153 | if start < 0 then return; end; |
| 154 | + deep := start - lineStart(start) + 3; | |
| 155 | + indent := -1; (* the indent of the code being written, or -1 *) | |
| 114 | 156 | i := start + 2; |
| 115 | 157 | j := stop - 2; |
| 116 | 158 | while (i < j) and Scan.isSpace(src[i]) do INC(i); end; |
| 117 | 159 | while (j > i) and Scan.isSpace(src[j - 1]) do DEC(j); end; |
| 118 | - atLine := true; | |
| 160 | + if man then control(".Bd -filled -offset indent -compact"); end; | |
| 119 | 161 | while i < j do |
| 120 | - if atLine then Out.str(" "); atLine := false; end; | |
| 121 | - Out.char(src[i]); | |
| 122 | - if src[i] = 10 then | |
| 123 | - atLine := true; | |
| 124 | - while (i + 1 < j) and (src[i + 1] = ' ') do INC(i); end; | |
| 162 | + k := i; | |
| 163 | + while (k < j) and (src[k] # 10) do INC(k); end; | |
| 164 | + n := 0; | |
| 165 | + while (i + n < k) and (src[i + n] = ' ') do INC(n); end; | |
| 166 | + if man and (n > deep) and (indent < 0) then | |
| 167 | + control(".Bd -literal -offset indent -compact"); | |
| 168 | + indent := n; | |
| 169 | + elsif man and (n <= deep) and (indent >= 0) then | |
| 170 | + control(".Ed"); | |
| 171 | + indent := -1; | |
| 125 | 172 | end; |
| 126 | - INC(i); | |
| 173 | + if man and (n = k - i) and (indent < 0) then control(".Pp"); | |
| 174 | + else | |
| 175 | + if not man then Out.str(" "); | |
| 176 | + elsif (indent >= 0) and (n > indent) then n := indent; | |
| 177 | + end; | |
| 178 | + for m := i + n to k - 1 do emit(src[m]); end; | |
| 179 | + emit(10); | |
| 180 | + end; | |
| 181 | + i := k + 1; | |
| 127 | 182 | end; |
| 128 | - Out.ln; | |
| 183 | + if indent >= 0 then control(".Ed"); end; | |
| 184 | + if man then control(".Ed"); end; | |
| 129 | 185 | end; |
| 130 | 186 | |
| 131 | -(* One declaration, from its first token, the comment before it kept. *) | |
| 187 | +(* One declaration, from its first token, the comment before it kept. | |
| 188 | + In mdoc a module's test, its main, is left out, and declarations | |
| 189 | + with no comment share a display. *) | |
| 132 | 190 | proc declaration(prefix: []U8; exported: BOOL; start, ds, de, stop: INT); |
| 133 | 191 | begin |
| 134 | 192 | if not exported then return; end; |
| 135 | - Out.ln; | |
| 136 | - Out.str(prefix); | |
| 193 | + if not man then Out.ln; | |
| 194 | + elsif Str.hasPrefix(src[start..stop], "proc main*") then return; | |
| 195 | + elsif not shown then control(".Bd -literal"); shown := true; | |
| 196 | + end; | |
| 197 | + if LEN(prefix) > 0 then Out.str(prefix); Out.str(" "); end; | |
| 137 | 198 | block(start, trailing(stop)); |
| 199 | + if ds >= 0 then close; end; | |
| 138 | 200 | comment(ds, de); |
| 139 | 201 | end; |
| 140 | 202 | |
| @@ -196,12 +258,7 @@ | ||
| 196 | 258 | sc.pos := sc.start; (* name reads the name again *) |
| 197 | 259 | exp := name(); |
| 198 | 260 | stop := toSemicolon(); |
| 199 | - if exp then | |
| 200 | - Out.ln; | |
| 201 | - Out.str(word); Out.str(" "); | |
| 202 | - block(start, trailing(stop)); | |
| 203 | - comment(ds, de); | |
| 204 | - end; | |
| 261 | + declaration(word, exp, start, ds, de, stop); | |
| 205 | 262 | next; |
| 206 | 263 | end; |
| 207 | 264 | end; |
| @@ -229,8 +286,15 @@ | ||
| 229 | 286 | if sc.kind = Scan.eof then Rt.stop("Doc: no module"); end; |
| 230 | 287 | start := sc.start; |
| 231 | 288 | ds := docStart; de := docEnd; |
| 232 | - block(start, toSemicolon()); | |
| 233 | - comment(ds, de); | |
| 289 | + next; | |
| 290 | + if man then | |
| 291 | + close; | |
| 292 | + Out.str(".Ss "); Out.str(text()); emit(10); | |
| 293 | + declaration("", true, start, ds, de, toSemicolon()); | |
| 294 | + else | |
| 295 | + block(start, toSemicolon()); | |
| 296 | + comment(ds, de); | |
| 297 | + end; | |
| 234 | 298 | next; |
| 235 | 299 | while (sc.kind # Scan.eof) and not is("begin") and not is("end") do |
| 236 | 300 | if is("const") or is("type") or is("var") then section; |
| @@ -337,11 +401,50 @@ | ||
| 337 | 401 | end; |
| 338 | 402 | end; |
| 339 | 403 | |
| 404 | +(* raz-lib(3): the modules named from argument 2 on, under a head and | |
| 405 | + above a tail of the page's own. *) | |
| 406 | +proc page; | |
| 407 | +var i: INT; | |
| 408 | +begin | |
| 409 | + man := true; | |
| 410 | + atStart := true; | |
| 411 | + control(".\\\" raz-lib(3) - the library; made by tools/Doc.raz from lib/"); | |
| 412 | + Out.str(".Dd "); Out.str(Date); emit(10); | |
| 413 | + control(".Dt RAZ-LIB 3"); | |
| 414 | + control(".Os"); | |
| 415 | + control(".Sh NAME"); | |
| 416 | + control(".Nm raz-lib"); | |
| 417 | + control(".Nd the library of the raz language"); | |
| 418 | + control(".Sh DESCRIPTION"); | |
| 419 | + control("The modules a raz program imports from"); | |
| 420 | + control(".Pa lib/ ,"); | |
| 421 | + control("beside the compiler, each as its source gives it: the module's own"); | |
| 422 | + control("comment, then every declaration it exports, as it is written, with"); | |
| 423 | + control("the comment just before it."); | |
| 424 | + control("A module's"); | |
| 425 | + control(".Ic main ,"); | |
| 426 | + control("where it has one, is its test, and is left out."); | |
| 427 | + control(".Pp"); | |
| 428 | + control("The report, section 11, says what the library promises, and which"); | |
| 429 | + control("of its modules every target has."); | |
| 430 | + control(".Sh MODULES"); | |
| 431 | + for i := 2 to ARGC() - 1 do document(Files.arg(i)); end; | |
| 432 | + close; | |
| 433 | + control(".Sh SEE ALSO"); | |
| 434 | + control(".Xr raz 1 ,"); | |
| 435 | + control(".Xr raz 7 ,"); | |
| 436 | + control(".Xr raz-tutorial 7 ;"); | |
| 437 | + control("the report,"); | |
| 438 | + control(".Pa doc/raz.md ,"); | |
| 439 | + control("in raz's sources."); | |
| 440 | +end; | |
| 441 | + | |
| 340 | 442 | proc main*; |
| 341 | 443 | begin |
| 342 | 444 | if (ARGC() = 4) and (Files.arg(1) = "examples") then examples(Files.arg(2), Files.arg(3)); |
| 445 | + elsif (ARGC() >= 3) and (Files.arg(1) = "man") then page; | |
| 343 | 446 | elsif ARGC() = 2 then document(Files.arg(1)); |
| 344 | - else Rt.stop("usage: Doc Module.raz, or Doc examples file dir"); | |
| 447 | + else Rt.stop("usage: Doc Module.raz, Doc man Module.raz ..., or Doc examples file dir"); | |
| 345 | 448 | end; |
| 346 | 449 | end; |
| 347 | 450 |