loader: remove shouting from ORB's variable name
[hvf.git] / cp / scripts / gen-docs.sh
blob3873e9b0088c15b917eea1ae9348599d3e695d61
1 write_docs()
3 cat "$1" | awk -v fmt="$2" '
4 BEGIN{
5 docdir = "doc/commands";
7 if (fmt == "txt") {
8 cmd_title_open = "";
9 cmd_title_close = "";
10 sec_hdr_open = "";
11 sec_hdr_close = "";
12 par_open = "";
13 par_close = "";
14 pre_open = "";
15 pre_close = "";
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>";
21 par_open = "<p>";
22 par_close = "</p>";
23 pre_open = "<pre>";
24 pre_close = "</pre>";
25 } else {
26 printf "ERROR: unknown format \"%s\"\n", fmt;
27 exit;
30 fname = "";
33 /^[/ ]\*!!! / {
34 # begin a new command
35 if (fname != "")
36 close(fname);
38 name="";
39 fname="";
40 for(i=2; i<=NF; i+=1) {
41 name = name $i " ";
42 fname = fname $i "_";
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;
50 print name >> fname;
51 print cmd_title_close >> fname;
54 /^[/ ]\*!! AUTH / {
55 # output an authorization block
56 print sec_hdr_open >> fname;
57 print "Authorization" >> fname;
58 print sec_hdr_close par_open >> fname;
59 print $3 >> 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;
70 /^[/ ]\*!! NOTES$/ {
71 # output notes section header
72 print sec_hdr_open >> fname;
73 print "Usage Notes" >> fname;
74 print sec_hdr_close >> fname;
77 /^[/ ]\*!p / {
78 # preformated verbatim line
79 print pre_open substr($0, 6) pre_close >> fname;
82 /^[/ ]\*! / {
83 # verbatim line
84 print substr($0, 5) >> fname;
87 /^[/ ]\*!$/ {
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..."
99 write_docs $srcf txt
100 write_docs $srcf html
101 done