]>
Commit | Line | Data |
---|---|---|
5496eda5 WD |
1 | #!/usr/bin/awk -f |
2 | ||
b5e539fc | 3 | # The caller must pass args: -v hfile=help-NAME.h NAME.NUM.md |
5496eda5 WD |
4 | |
5 | BEGIN { | |
6 | heading = "/* DO NOT EDIT THIS FILE! It is auto-generated from the option list in " ARGV[1] "! */" | |
b5e539fc | 7 | findcomment = hfile |
5496eda5 WD |
8 | sub("\\.", "\\.", findcomment) |
9 | findcomment = "\\[comment\\].*" findcomment | |
10 | backtick_cnt = 0 | |
11 | prints = "" | |
12 | } | |
13 | ||
14 | /^```/ { | |
15 | backtick_cnt++ | |
16 | next | |
17 | } | |
18 | ||
19 | foundcomment { | |
20 | if (backtick_cnt > 1) exit | |
21 | if (backtick_cnt == 1) { | |
22 | gsub(/"/, "\\\"") | |
23 | prints = prints "\n rprintf(F,\"" $0 "\\n\");" | |
24 | } | |
25 | next | |
26 | } | |
27 | ||
28 | $0 ~ findcomment { | |
29 | foundcomment = 1 | |
30 | backtick_cnt = 0 | |
31 | } | |
32 | ||
33 | END { | |
34 | if (foundcomment && backtick_cnt > 1) | |
b5e539fc | 35 | print heading "\n" prints > hfile |
5496eda5 | 36 | else { |
b5e539fc | 37 | print "Failed to find " hfile " section in " ARGV[1] |
5496eda5 WD |
38 | exit 1 |
39 | } | |
40 | } |