diff options
author | Steve Bennett <steveb@workware.net.au> | 2011-09-01 11:29:57 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2011-09-02 14:37:15 +1000 |
commit | 8a0fa552e9f8c24619a815fa09201ebff41448ee (patch) | |
tree | 901750571c29dcead8ee4b7c09653f598c18dec6 /make-index | |
parent | c76804182231ccfe08e3b7b9435e1b498bf83f59 (diff) | |
download | jimtcl-8a0fa552e9f8c24619a815fa09201ebff41448ee.zip jimtcl-8a0fa552e9f8c24619a815fa09201ebff41448ee.tar.gz jimtcl-8a0fa552e9f8c24619a815fa09201ebff41448ee.tar.bz2 |
Updates to the manual for hyperlinked commands
Also various formatting improvements.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'make-index')
-rwxr-xr-x | make-index | 48 |
1 files changed, 29 insertions, 19 deletions
@@ -4,16 +4,10 @@ set filename [lindex $argv 0] set f [open $filename] -while {[gets $f buf] >= 0} { - if {$buf eq "@INSERTINDEX@"} { - break - } - puts $buf -} - -# Collect lines and commands +# Read the file looking for command definitions set lines {} set commands {} +array set cdict {} set c 0 while {[gets $f buf] >= 0} { @@ -27,8 +21,9 @@ while {[gets $f buf] >= 0} { } foreach cmd [split $prev ":,"] { set cmd [string trim $cmd] - if {$cmd ne ""} { + if {[regexp {^[a-z.]+$} $cmd]} { lappend commands [list $cmd $target] + set cdict($cmd) $target } } } @@ -37,24 +32,39 @@ while {[gets $f buf] >= 0} { } close $f -# Output the index -puts {[frame="none",grid="none"]} -puts {|=========================} +# Build the command index in the list: $index +lappend index {[frame="none",grid="none"]} +lappend index {|=========================} set i 0 +set row {} foreach command [lsort $commands] { - foreach {cmd target} $command break + lassign $command cmd target - puts -nonewline "|<<$target,$cmd>> " + append row "|<<$target,*`$cmd`*>> " incr i if {$i % 8 == 0} { - puts "" + lappend index $row + set row {} } } while {$i % 8 != 0} { incr i - puts -nonewline "| " + append row "| " } -puts "" -puts {|=========================} +lappend index $row +lappend index {|=========================} -puts [join $lines \n] +# Map all `cmd` to <<$target,`cmd`>> +set mapping {} +foreach c [array names cdict] { + lappend mapping `$c` <<$cdict($c),*`$c`*>> + lappend mapping "`$c " "<<$cdict($c),*`$c`*>> `" +} + +# And the command index +lappend mapping @INSERTINDEX@ [join $index \n] + +# Output the result +foreach line $lines { + puts [string map $mapping $line] +} |