aboutsummaryrefslogtreecommitdiff
path: root/make-index
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2010-11-03 16:27:40 +1000
committerSteve Bennett <steveb@workware.net.au>2010-11-03 18:57:02 +1000
commitcba565f4ccd4a667cc3b51108fae55cc735b36aa (patch)
tree3d42722d76f7f3cd96bfaea868f880b36215fe1b /make-index
parent298a9911f7a94c179829cc67d240d1b4cde7583b (diff)
downloadjimtcl-cba565f4ccd4a667cc3b51108fae55cc735b36aa.zip
jimtcl-cba565f4ccd4a667cc3b51108fae55cc735b36aa.tar.gz
jimtcl-cba565f4ccd4a667cc3b51108fae55cc735b36aa.tar.bz2
Autogenerate the command index in the documentation
This was lost in the merge of the WorkWare fork Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'make-index')
-rwxr-xr-xmake-index60
1 files changed, 60 insertions, 0 deletions
diff --git a/make-index b/make-index
new file mode 100755
index 0000000..944d94e
--- /dev/null
+++ b/make-index
@@ -0,0 +1,60 @@
+#!/usr/bin/env tclsh
+# vim:se syn=tcl:
+
+lassign $argv filename
+set f [open $filename]
+
+while {[gets $f buf] >= 0} {
+ if {$buf eq "@INSERTINDEX@"} {
+ break
+ }
+ puts $buf
+}
+
+# Collect lines and commands
+set lines {}
+set commands {}
+set c 0
+
+while {[gets $f buf] >= 0} {
+ if {[string match "~~*" $buf]} {
+ if {[string match "*:*" $prev]} {
+ incr c
+ set target cmd_$c
+ set lines [linsert $lines end-1 "\[\[$target\]\]"]
+ } else {
+ set target _$prev
+ }
+ foreach cmd [split $prev ":,"] {
+ set cmd [string trim $cmd]
+ if {$cmd ne ""} {
+ lappend commands [list $cmd $target]
+ }
+ }
+ }
+ lappend lines $buf
+ set prev $buf
+}
+close $f
+
+# Output the index
+puts {[frame="none",grid="none"]}
+puts {|=========================}
+set i 0
+foreach command [lsort $commands] {
+ foreach {cmd target} $command break
+
+ puts -nonewline "|<<$target,$cmd>> "
+ incr i
+ if {$i % 8 == 0} {
+ puts ""
+ }
+}
+while {$i % 8 != 0} {
+ incr i
+ puts -nonewline "| "
+}
+puts ""
+puts {|=========================}
+
+puts [join $lines \n]