little pipadoc cleanup, sort index case independenty
authorChristian Thaeter <ct@pipapo.org>
Fri, 19 Jun 2009 07:19:35 +0000 (09:19 +0200)
committerChristian Thaeter <ct@pipapo.org>
Fri, 4 Sep 2009 04:31:59 +0000 (06:31 +0200)
doc/asciidoc.pawk
pipadoc

index bc36095..13e7a99 100644 (file)
@@ -2,7 +2,7 @@
 # Create an asciidoc paragraph and index entry
 #             Sec       Name  Index Explanation
 match($0, com"(.*) PARA (.*); (.*); *(.*)", p) {
-  append("index", p[3], "xref:"p[3]"["p[2]"]:: "p[4])
+  append("index", tolower(p[3]), "xref:"p[3]"["p[2]"]:: "p[4])
   append(p[1],"","[["p[3]"]]")
   append(p[1],"","."p[2])
   next
@@ -11,7 +11,7 @@ match($0, com"(.*) PARA (.*); (.*); *(.*)", p) {
 # Create an asciidoc headline and index entry
 #             Sec      Typ Name  Index Explanation
 match($0, com"(.*) HEAD(.) (.*); (.*); *(.*)", p) {
-  append("index", p[4], "xref:"p[4]"["p[3]"]:: "p[5])
+  append("index", tolower(p[4]), "xref:"p[4]"["p[3]"]:: "p[5])
   append(p[1],"","[["p[4]"]]")
   append(p[1],"",p[3])
   append(p[1],"",gensub(/./, p[2], "g", p[3]))
diff --git a/pipadoc b/pipadoc
index ff4da95..b9df472 100755 (executable)
--- a/pipadoc
+++ b/pipadoc
@@ -158,7 +158,7 @@ gawk -f /dev/fd/3 ${COM:+-v com="$COM"} ${DOC:+-v doc="$DOC"} ${SUB:+-v subs="$S
 function append(idx, sort, text)
 {
   if (idx in maybe)
-    maybe[idx] = maybe[idx] "\n.. " text
+    maybe[idx] = maybe[idx] "\n."sort" " text
   else
     maybe[idx] = "."sort" "text
 }
@@ -187,8 +187,6 @@ match(\$0, com doc "([[:space:]](.*))?\$", s) {
 
 # record all other comments which may be candidate comments
 match(\$0, "(.*)" com "([[:alpha:]][[:alnum:]_]*)(([.]([^[:space:]]*)))?([[:space:]](.*))?", m) && m[1] !~ com {
-  #print "append("m[2]"," m[5] "," m[7]")"
-
   append(m[2], m[5] , m[7])
   next
 }
@@ -201,17 +199,18 @@ END {
         print output[i]
       else
         {
-          nelements = split(maybe[subst[i]], s, "\n[.]")
-          split("", tosort)
+          nelements = split(maybe[subst[i]], s, "\n")
+          delete tosort
+          #split("", tosort)
 
-          for (j=1; j <=nelements; ++j)
+          for (j=1; j <= nelements; ++j)
             {
-              match(s[j], ".([^[:space:]]*) (.*)", entries)
+              match(s[j], "[.]([^[:space:]]*) (.*)", entries)
 
-              if ("." entries[1] in tosort)
-                tosort["." entries[1]] = tosort["." entries[1]] "\n" entries[2]
+              if (entries[1] in tosort)
+                tosort[entries[1]] = tosort[entries[1]] "\n" entries[2]
               else
-                tosort["." entries[1]] = entries[2]
+                tosort[entries[1]] = entries[2]
             }
 
           elements = asorti(tosort, sorted)