3 cat "$1" |
awk -v fmt="$2" '
5 docdir = "doc/commands";
16 } else if (fmt == "html") {
17 cmd_title_open = "<h1>";
18 cmd_title_close = "</h1>";
19 sec_hdr_open = "<h2>";
20 sec_hdr_close = "</h2>";
26 printf "ERROR: unknown format \"%s\"\n", fmt;
40 for(i=2; i<=NF; i+=1) {
44 name = substr(name, 1, length(name)-1);
45 fname = docdir "/" fmt "/" substr(fname, 1, length(fname)-1) "." fmt;
47 print "Writing out ", fname;
49 print cmd_title_open > fname;
51 print cmd_title_close >> fname;
55 # output an authorization block
56 print sec_hdr_open >> fname;
57 print "Authorization" >> fname;
58 print sec_hdr_close par_open >> fname;
60 printf par_close >> fname;
63 /^[/ ]\*!! PURPOSE$/ {
64 # output purpose section header
65 print sec_hdr_open >> fname;
66 print "Purpose" >> fname;
67 print sec_hdr_close >> fname;
71 # output notes section header
72 print sec_hdr_open >> fname;
73 print "Usage Notes" >> fname;
74 print sec_hdr_close >> fname;
78 # preformated verbatim line
79 print pre_open substr($0, 6) pre_close >> fname;
84 print substr($0, 5) >> fname;
88 # just make a new paragraph
89 print substr($0, 5) >> fname;
94 mkdir
-p doc
/commands
/txt
95 mkdir
-p doc
/commands
/html
97 for srcf
in shell
/cmd_
*.c
; do
98 echo "Inspecting $srcf..."
100 write_docs
$srcf html