File: gen_index.tcl

package info (click to toggle)
tcllib 1.10-dfsg-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 17,708 kB
  • ctags: 6,122
  • sloc: tcl: 106,354; ansic: 9,205; sh: 8,707; xml: 1,766; yacc: 753; makefile: 115; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (73 lines) | stat: -rw-r--r-- 1,466 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/tclsh

set docdir [lindex $argv 0]
set manuals {}

foreach docfile [glob -nocomplain -directory $docdir *.html] {
    puts stderr $docfile

    if {[catch {set fd [open $docfile]} msg]} {
	puts stderr "Can't open file $docfile: $msg"
	continue
    }

    while {[gets $fd line] >= 0} {
	if {[regexp {<h1>\s*(.*)\((3tcl)?\)\s+(\S+)\s+(\S+)\s+(.*)</h1>} $line -> \
		    name - version module title]} {
	    lappend manuals [list $module!$title!$name $module $name $version $title [file tail $docfile]]
	    break
	}
    }
    close $fd
}

puts "<html>
<head>
<title>Tcllib HTML Documentation</title>
<style type=\"text/css\">
<!--
ul {
    background: lightyellow;
    border-style: solid;
    border-width: 1px;
    border-color: black;
}
li {
    padding: 3px;
}
li a {
    font-weight: bold;
}
-->
</style>
</head>
<body>
<h1>Tcllib HTML Documentation</h1>"

set manuals [lsort -index 0 $manuals]
set prev ""
set prevtitle ""
foreach m $manuals {
    set module  [lindex $m 1]
    set name    [lindex $m 2]
    set version [lindex $m 3]
    set title   [lindex $m 4]
    set fname   [lindex $m 5]

    if {$module != $prev} {
	if {$prev != ""} {
	    puts "</ul>"
	}
	puts "<h2>$module: $title</h2>\n<ul>"
	set prev $module
	set prevtitle $title
    } elseif {$title != $prevtitle} {
	puts "</ul>\n<h2>$module: $title</h2>\n<ul>"
	set prevtitle $title
    }
    puts "<li><a href=\"html/$fname\">$name</a> $version</li>"
}
puts "</ul>
</body>
</html>"