aboutsummaryrefslogtreecommitdiff
path: root/make-index
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2011-09-01 11:29:57 +1000
committerSteve Bennett <steveb@workware.net.au>2011-09-02 14:37:15 +1000
commit8a0fa552e9f8c24619a815fa09201ebff41448ee (patch)
tree901750571c29dcead8ee4b7c09653f598c18dec6 /make-index
parentc76804182231ccfe08e3b7b9435e1b498bf83f59 (diff)
downloadjimtcl-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-xmake-index48
1 files changed, 29 insertions, 19 deletions
diff --git a/make-index b/make-index
index 37eda49..8dba920 100755
--- a/make-index
+++ b/make-index
@@ -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]
+}