From cba565f4ccd4a667cc3b51108fae55cc735b36aa Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Wed, 3 Nov 2010 16:27:40 +1000 Subject: Autogenerate the command index in the documentation This was lost in the merge of the WorkWare fork Signed-off-by: Steve Bennett --- make-index | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 make-index (limited to 'make-index') 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] -- cgit v1.1