include source file and line number comments by asciidoc.pawk
[nobug] / doc / asciidoc.pawk
1
2 # include asciidoc comments about filename and linenumber in generated document
3 match($0, com "([[:alpha:]][[:alnum:]_]*)(([.]([^[:space:]]*)))?", p) {
4     if(p[1] != old_index)
5     {
6         old_index = p[1]
7         append(p[1], p[4], "// "FILENAME ":" FNR " //")
8     }
9 }
10
11 # Create an asciidoc paragraph and index entry
12 #             Sec       Name  Index Explanation
13 match($0, com"(.*) PARA (.*); *(.*); *(.*)", p) {
14     if(p[3])
15     {
16         append("index", tolower(p[3]), "xref:"p[3]"["p[2]"]:: "p[4])
17         append(p[1],"","[["p[3]"]]")
18     }
19     append(p[1],"","."p[2])
20     next
21 }
22
23 # Create an asciidoc headline and index entry
24 #             Sec      Typ Name  Index Explanation
25 match($0, com"(.*) HEAD(.) (.*); *(.*); *(.*)", p) {
26     if (p[4])
27     {
28         append("index", tolower(p[4]), "xref:"p[4]"["p[3]"]:: "p[5])
29         append(p[1],"","[["p[4]"]]")
30     }
31     append(p[1],"",p[3])
32     append(p[1],"",gensub(/./, p[2], "g", p[3]))
33     next
34 }
35