os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tools/man2html.tcl
First public contribution.
1 #!/proj/tcl/install/5.x-sparc/bin/tclsh7.5
7 # This file contains procedures that work in conjunction with the
8 # man2tcl program to generate a HTML files from Tcl manual entries.
10 # Copyright (c) 1996 by Sun Microsystems, Inc.
12 # SCCS: @(#) man2html.tcl 1.5 96/04/11 20:21:43
15 set homeDir /home/rjohnson/Projects/tools/generic
19 # Save an array to a file so that it can be sourced.
22 # file - Name of the output file
23 # args - Name of the arrays to save
25 proc sarray {file args} {
26 set file [open $file w]
29 if ![array exists array] {
30 puts "sarray: \"$a\" isn't an array"
34 foreach name [lsort [array names array]] {
35 regsub -all " " $name "\\ " name1
36 puts $file "set ${a}($name1) \{$array($name)\}"
46 # Builds footer info for HTML pages
51 proc footer {packages} {
54 foreach package $packages {
55 lappend h "<A HREF=\"../$package/contents.html\">$package</A>"
58 lappend f [join [lreplace $h end end {]} ] " "]
60 lappend f "<PRE>Copyright © 1989-1994 The Regents of the University of California."
61 lappend f "Copyright © 1994-1996 Sun Microsystems, Inc."
71 # Given a directory as argument, translate all the man pages in
75 # dir - Name of the directory.
78 foreach f [lsort [glob -directory $dir "*.\[13n\]"]] {
79 do $f ;# defined in man2html1.tcl & man2html2.tcl
85 puts stderr "usage: $argv0 html_dir tcl_dir packages..."
86 puts stderr "usage: $argv0 -clean html_dir"
90 if {[lindex $argv 0] == "-clean"} {
91 set html_dir [lindex $argv 1]
92 puts -nonewline "recursively remove: $html_dir? "
94 if {[gets stdin] == "y"} {
95 puts "removing: $html_dir"
101 set html_dir [lindex $argv 0]
102 set tcl_dir [lindex $argv 1]
103 set packages [lrange $argv 2 end]
105 #### need to add glob capability to packages ####
107 # make sure there are doc directories for each package
109 foreach i $packages {
110 if ![file exists $tcl_dir/$i/doc] {
111 puts stderr "Error: doc directory for package $i is missing"
114 if ![file isdirectory $tcl_dir/$i/doc] {
115 puts stderr "Error: $tcl_dir/$i/doc is not a directory"
121 # we want to start with a clean sheet
123 if [file exists $html_dir] {
124 puts stderr "Error: HTML directory already exists"
130 set footer [footer $packages]
133 # make the hyperlink arrays and contents.html for all packages
135 foreach package $packages {
137 exec mkdir $html_dir/$package
139 # build hyperlink database arrays: NAME_file and KEY_file
141 puts "\nScanning man pages in $tcl_dir/$package/doc..."
142 source $homeDir/man2html1.tcl
144 doDir $tcl_dir/$package/doc
146 # clean up the NAME_file and KEY_file database arrays
148 catch {unset KEY_file()}
149 foreach name [lsort [array names NAME_file]] {
150 set file_name $NAME_file($name)
151 if {[llength $file_name] > 1} {
152 set file_name [lsort $file_name]
153 puts stdout "Warning: '$name' multiply defined in: $file_name; using last"
154 set NAME_file($name) [lindex $file_name end]
157 # sarray $html_dir/$package/xref.tcl NAME_file KEY_file
159 # build the contents file from NAME_file
161 puts "\nGenerating contents.html for $package"
162 doContents $html_dir/$package/contents.html $lib ;# defined in man2html1.tcl
164 # now translate the man pages to HTML pages
166 source $homeDir/man2html2.tcl
167 puts "\nBuilding html pages from man pages in $tcl_dir/$package/doc..."
168 doDir $tcl_dir/$package/doc
179 puts stderr $errorInfo