diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2006-12-06 14:46:46 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2006-12-06 14:46:46 +0000 |
commit | 5bdcb13056d609c8bd0cbf10ae5ba2a5a48e5037 (patch) | |
tree | 5eb8643a5720d0d18664780966a416dbd02d3658 | |
parent | d0d9b5cf1a7664b762c71d8e253976797340730b (diff) | |
download | mailfromd-5bdcb13056d609c8bd0cbf10ae5ba2a5a48e5037.tar.gz mailfromd-5bdcb13056d609c8bd0cbf10ae5ba2a5a48e5037.tar.bz2 |
Handle @multitable blocks. Print a diagnostic message if some other function is required
git-svn-id: file:///svnroot/mailfromd/trunk@1091 7a8a7f39-df28-0410-adc6-e0d955640f24
-rw-r--r-- | doc/extract.awk | 75 |
1 files changed, 60 insertions, 15 deletions
diff --git a/doc/extract.awk b/doc/extract.awk index 9d3c00b1..63996214 100644 --- a/doc/extract.awk +++ b/doc/extract.awk @@ -17,16 +17,17 @@ # MA 02110-1301 USA BEGIN { - if (SELECT) { - n = split(SELECT, a, ",") - for (i = 1; i <= n; i++) - select[a[i]] = 1 - } + if (SELECT) { + gsub(/,$/,"", SELECT) + n = split(SELECT, a, ",") + for (i = 1; i <= n; i++) + select[a[i]] = 1 + } } function error(s) { - print "extract.awk: " ARGV[1] ":" NR ": " s > "/dev/stderr" + print "extract.awk: " ARGV[1] ":" NR ": " s > "/dev/stderr" } function output(file, s) @@ -38,6 +39,27 @@ function output(file, s) print s > file } +function sprintf_multitab(s, a, n, i, r) +{ + sub(/@(head)?item/, "", s) + n = split(s, a, /@tab/) + r = "" + for (i = 1; i <= n; i++) + r = r "" sprintf("%-*s", multitable[i-1], a[i]) + return r +} + +function flush_mtline( s) +{ + if (match(mtline, "@headitem")) { + s = sprintf_multitab(mtline) + output(file, "# " s) + gsub(/./, "-", s) + output(file, "# " s) + } else + output(file, "# " sprintf_multitab(mtline)) +} + state == 0 && /^@deftypefn[ \t]+{Sample[ \t]+Function}/ { name = $5 if (SELECT && !select[name]) @@ -46,10 +68,10 @@ state == 0 && /^@deftypefn[ \t]+{Sample[ \t]+Function}/ { notified = 0 state = 1 if (match($0, ".*@$")) { - save0 = substr($0, 1, length($0)-1) - while (getline > 0 && match($0, ".*@$")) - save0 = save0 substr($0, 1, length($0)-1) - $0 = save0 $0 + save0 = substr($0, 1, length($0)-1) + while (getline > 0 && match($0, ".*@$")) + save0 = save0 substr($0, 1, length($0)-1) + $0 = save0 $0 } } @@ -63,10 +85,27 @@ state == 0 { next } state == 1 && /^[ \t]*@smallexample/ { state = 2; next } state == 2 && /^@end[ \t]+smallexample/ { state = 1; next } +state == 2 && /#include/ { + s = $2 + gsub(/[<>\"]/,"",s) + gsub(/\.mf$/,"",s) + if (SELECT && !select[s]) + print "Require " s +} state == 1 && /^[ \t]*@table/ { state = 3; table = $2; next } state == 3 && /^@end[ \t]+table/ { state = 1; next } +state == 1 && /^[ \t]*@multitable/ { + state = 6; + delete multitable + mtcount = 0 + for (i = 3; i <= NF; i++) + multitable[mtcount++] = $i * 78 + next +} +state == 6 && /^@end[ \t]+multitable/ { flush_mtline(); state = 1; next } + # Parse texinfo commands: /^[ \t]*@c[ \t]/ { next } @@ -94,18 +133,24 @@ state == 3 && /^@itemx*/ { gsub(/@result{}/, "=>") $0 = gensub(/@samp{([^}]*)}/, "`\\1'", "g") while (match($0, "@var{[^}]*}")) { - $0 = substr($0, 1, RSTART-1) toupper(substr($0, RSTART+5, RLENGTH-6)) substr($0, RSTART+RLENGTH) + $0 = substr($0, 1, RSTART-1) \ + toupper(substr($0, RSTART+5, RLENGTH-6)) \ + substr($0, RSTART+RLENGTH) } $0 = gensub(/@[a-z]+{([^}]*)}/, "\\1", "g") } /^@deftypefn[ \t]+{Sample[ \t]+Function}/ { - s = "" - for (i = 4; i <= NF; i++) - s = s " " $i - $0 = s + s = "" + for (i = 4; i <= NF; i++) + s = s " " $i + $0 = s } +state == 6 && /@item/ { flush_mtline(); mtline = $0; next } +state == 6 && /@headitem/ { flush_mtline(); mtline = $0; next } +state == 6 { mtline = mtline " " $0; next } + # Remove any leftover commands /^[ \t]*@.*/ { next } |