| 1 |
#!/usr/bin/env tclsh |
| 2 |
|
| 3 |
if {[catch {package require Tcl 8.6-} msg]} { |
| 4 |
puts stderr "ERROR: $msg" |
| 5 |
puts stderr "If running this script from 'make html', set the\ |
| 6 |
NATIVE_TCLSH environment\nvariable to point to an installed\ |
| 7 |
tclsh8.6 (or the equivalent tclsh86.exe\non Windows)." |
| 8 |
exit 1 |
| 9 |
} |
| 10 |
|
| 11 |
# Convert Ousterhout format man pages into highly crosslinked hypertext. |
| 12 |
# |
| 13 |
# Along the way detect many unmatched font changes and other odd things. |
| 14 |
# |
| 15 |
# Note well, this program is a hack rather than a piece of software |
| 16 |
# engineering. In that sense it's probably a good example of things |
| 17 |
# that a scripting language, like Tcl, can do well. It is offered as |
| 18 |
# an example of how someone might convert a specific set of man pages |
| 19 |
# into hypertext, not as a general solution to the problem. If you |
| 20 |
# try to use this, you'll be very much on your own. |
| 21 |
# |
| 22 |
# Copyright (c) 1995-1997 Roger E. Critchlow Jr |
| 23 |
# Copyright (c) 2004-2010 Donal K. Fellows |
| 24 |
|
| 25 |
set ::Version "50/8.6" |
| 26 |
set ::CSSFILE "docs.css" |
| 27 |
|
| 28 |
## |
| 29 |
## Source the utility functions that provide most of the |
| 30 |
## implementation of the transformation from nroff to html. |
| 31 |
## |
| 32 |
source -encoding utf-8 [file join [file dirname [info script]] tcltk-man2html-utils.tcl] |
| 33 |
|
| 34 |
proc parse_command_line {} { |
| 35 |
global argv Version |
| 36 |
|
| 37 |
# These variables determine where the man pages come from and where |
| 38 |
# the converted pages go to. |
| 39 |
global tcltkdir tkdir tcldir webdir build_tcl build_tk verbose |
| 40 |
|
| 41 |
# Set defaults based on original code. |
| 42 |
set tcltkdir ../.. |
| 43 |
set tkdir {} |
| 44 |
set tcldir {} |
| 45 |
set webdir ../html |
| 46 |
set build_tcl 0 |
| 47 |
set build_tk 0 |
| 48 |
set verbose 0 |
| 49 |
# Default search version is a glob pattern |
| 50 |
set useversion {{,[8-9].[0-9]{,[.ab][0-9]{,[0-9]}}}} |
| 51 |
|
| 52 |
# Handle arguments a la GNU: |
| 53 |
# --version |
| 54 |
# --useversion=<version> |
| 55 |
# --help |
| 56 |
# --srcdir=/path |
| 57 |
# --htmldir=/path |
| 58 |
|
| 59 |
foreach option $argv { |
| 60 |
switch -glob -- $option { |
| 61 |
--version { |
| 62 |
puts "tcltk-man-html $Version" |
| 63 |
exit 0 |
| 64 |
} |
| 65 |
|
| 66 |
--help { |
| 67 |
puts "usage: tcltk-man-html \[OPTION\] ...\n" |
| 68 |
puts " --help print this help, then exit" |
| 69 |
puts " --version print version number, then exit" |
| 70 |
puts " --srcdir=DIR find tcl and tk source below DIR" |
| 71 |
puts " --htmldir=DIR put generated HTML in DIR" |
| 72 |
puts " --tcl build tcl help" |
| 73 |
puts " --tk build tk help" |
| 74 |
puts " --useversion version of tcl/tk to search for" |
| 75 |
puts " --verbose whether to print longer messages" |
| 76 |
exit 0 |
| 77 |
} |
| 78 |
|
| 79 |
--srcdir=* { |
| 80 |
# length of "--srcdir=" is 9. |
| 81 |
set tcltkdir [string range $option 9 end] |
| 82 |
} |
| 83 |
|
| 84 |
--htmldir=* { |
| 85 |
# length of "--htmldir=" is 10 |
| 86 |
set webdir [string range $option 10 end] |
| 87 |
} |
| 88 |
|
| 89 |
--useversion=* { |
| 90 |
# length of "--useversion=" is 13 |
| 91 |
set useversion [string range $option 13 end] |
| 92 |
} |
| 93 |
|
| 94 |
--tcl { |
| 95 |
set build_tcl 1 |
| 96 |
} |
| 97 |
|
| 98 |
--tk { |
| 99 |
set build_tk 1 |
| 100 |
} |
| 101 |
|
| 102 |
--verbose=* { |
| 103 |
set verbose [string range $option \ |
| 104 |
[string length --verbose=] end] |
| 105 |
} |
| 106 |
default { |
| 107 |
puts stderr "tcltk-man-html: unrecognized option -- `$option'" |
| 108 |
exit 1 |
| 109 |
} |
| 110 |
} |
| 111 |
} |
| 112 |
|
| 113 |
if {!$build_tcl && !$build_tk} { |
| 114 |
set build_tcl 1; |
| 115 |
set build_tk 1 |
| 116 |
} |
| 117 |
|
| 118 |
if {$build_tcl} { |
| 119 |
# Find Tcl |
| 120 |
set tcldir [lindex [lsort [glob -nocomplain -tails -type d \ |
| 121 |
-directory $tcltkdir tcl$useversion]] end] |
| 122 |
if {$tcldir eq ""} { |
| 123 |
puts stderr "tcltk-man-html: couldn't find Tcl below $tcltkdir" |
| 124 |
exit 1 |
| 125 |
} |
| 126 |
puts "using Tcl source directory $tcldir" |
| 127 |
} |
| 128 |
|
| 129 |
if {$build_tk} { |
| 130 |
# Find Tk |
| 131 |
set tkdir [lindex [lsort [glob -nocomplain -tails -type d \ |
| 132 |
-directory $tcltkdir tk$useversion]] end] |
| 133 |
if {$tkdir eq ""} { |
| 134 |
puts stderr "tcltk-man-html: couldn't find Tk below $tcltkdir" |
| 135 |
exit 1 |
| 136 |
} |
| 137 |
puts "using Tk source directory $tkdir" |
| 138 |
} |
| 139 |
|
| 140 |
puts "verbose messages are [expr {$verbose ? {on} : {off}}]" |
| 141 |
|
| 142 |
# the title for the man pages overall |
| 143 |
global overall_title |
| 144 |
set overall_title "" |
| 145 |
if {$build_tcl} { |
| 146 |
append overall_title "[capitalize $tcldir]" |
| 147 |
} |
| 148 |
if {$build_tcl && $build_tk} { |
| 149 |
append overall_title "/" |
| 150 |
} |
| 151 |
if {$build_tk} { |
| 152 |
append overall_title "[capitalize $tkdir]" |
| 153 |
} |
| 154 |
append overall_title " Documentation" |
| 155 |
} |
| 156 |
|
| 157 |
proc capitalize {string} { |
| 158 |
return [string toupper $string 0] |
| 159 |
} |
| 160 |
|
| 161 |
## |
| 162 |
## Returns the style sheet. |
| 163 |
## |
| 164 |
proc css-style args { |
| 165 |
upvar 1 style style |
| 166 |
set body [uplevel 1 [list subst [lindex $args end]]] |
| 167 |
set tokens [join [lrange $args 0 end-1] ", "] |
| 168 |
append style $tokens " \{" $body "\}\n" |
| 169 |
} |
| 170 |
proc css-stylesheet {} { |
| 171 |
set hBd "1px dotted #11577B" |
| 172 |
|
| 173 |
css-style body div p th td li dd ul ol dl dt blockquote { |
| 174 |
font-family: Verdana, sans-serif; |
| 175 |
} |
| 176 |
css-style pre code { |
| 177 |
font-family: 'Courier New', Courier, monospace; |
| 178 |
} |
| 179 |
css-style pre { |
| 180 |
background-color: #F6FCEC; |
| 181 |
border-top: 1px solid #6A6A6A; |
| 182 |
border-bottom: 1px solid #6A6A6A; |
| 183 |
padding: 1em; |
| 184 |
overflow: auto; |
| 185 |
} |
| 186 |
css-style body { |
| 187 |
background-color: #FFFFFF; |
| 188 |
font-size: 12px; |
| 189 |
line-height: 1.25; |
| 190 |
letter-spacing: .2px; |
| 191 |
padding-left: .5em; |
| 192 |
} |
| 193 |
css-style h1 h2 h3 h4 { |
| 194 |
font-family: Georgia, serif; |
| 195 |
padding-left: 1em; |
| 196 |
margin-top: 1em; |
| 197 |
} |
| 198 |
css-style h1 { |
| 199 |
font-size: 18px; |
| 200 |
color: #11577B; |
| 201 |
border-bottom: $hBd; |
| 202 |
margin-top: 0px; |
| 203 |
} |
| 204 |
css-style h2 { |
| 205 |
font-size: 14px; |
| 206 |
color: #11577B; |
| 207 |
background-color: #C5DCE8; |
| 208 |
padding-left: 1em; |
| 209 |
border: 1px solid #6A6A6A; |
| 210 |
} |
| 211 |
css-style h3 h4 { |
| 212 |
color: #1674A4; |
| 213 |
background-color: #E8F2F6; |
| 214 |
border-bottom: $hBd; |
| 215 |
border-top: $hBd; |
| 216 |
} |
| 217 |
css-style h3 { |
| 218 |
font-size: 12px; |
| 219 |
} |
| 220 |
css-style h4 { |
| 221 |
font-size: 11px; |
| 222 |
} |
| 223 |
css-style ".keylist dt" ".arguments dt" { |
| 224 |
width: 25em; |
| 225 |
float: left; |
| 226 |
padding: 2px; |
| 227 |
border-top: 1px solid #999999; |
| 228 |
} |
| 229 |
css-style ".keylist dt" { font-weight: bold; } |
| 230 |
css-style ".keylist dd" ".arguments dd" { |
| 231 |
margin-left: 25em; |
| 232 |
padding: 2px; |
| 233 |
border-top: 1px solid #999999; |
| 234 |
} |
| 235 |
css-style .copy { |
| 236 |
background-color: #F6FCFC; |
| 237 |
white-space: pre; |
| 238 |
font-size: 80%; |
| 239 |
border-top: 1px solid #6A6A6A; |
| 240 |
margin-top: 2em; |
| 241 |
} |
| 242 |
css-style .tablecell { |
| 243 |
font-size: 12px; |
| 244 |
padding-left: .5em; |
| 245 |
padding-right: .5em; |
| 246 |
} |
| 247 |
} |
| 248 |
|
| 249 |
## |
| 250 |
## foreach of the man directories specified by args |
| 251 |
## convert manpages into hypertext in the directory |
| 252 |
## specified by html. |
| 253 |
## |
| 254 |
proc make-man-pages {html args} { |
| 255 |
global manual overall_title tcltkdesc verbose |
| 256 |
global excluded_pages forced_index_pages process_first_patterns |
| 257 |
|
| 258 |
makedirhier $html |
| 259 |
set cssfd [open $html/$::CSSFILE w] |
| 260 |
fconfigure $cssfd -translation lf -encoding utf-8 |
| 261 |
puts $cssfd [css-stylesheet] |
| 262 |
close $cssfd |
| 263 |
set manual(short-toc-n) 1 |
| 264 |
set manual(short-toc-fp) [open $html/[indexfile] w] |
| 265 |
fconfigure $manual(short-toc-fp) -translation lf -encoding utf-8 |
| 266 |
puts $manual(short-toc-fp) [htmlhead $overall_title $overall_title] |
| 267 |
puts $manual(short-toc-fp) "<DL class=\"keylist\">" |
| 268 |
set manual(merge-copyrights) {} |
| 269 |
|
| 270 |
foreach arg $args { |
| 271 |
# preprocess to set up subheader for the rest of the files |
| 272 |
if {![llength $arg]} { |
| 273 |
continue |
| 274 |
} |
| 275 |
lassign $arg -> name file |
| 276 |
if {[regexp {(.*)(?: Package)? Commands(?:, version .*)?} $name -> pkg]} { |
| 277 |
set name "$pkg Commands" |
| 278 |
} elseif {[regexp {(.*)(?: Package)? C API(?:, version .*)?} $name -> pkg]} { |
| 279 |
set name "$pkg C API" |
| 280 |
} |
| 281 |
lappend manual(subheader) $name $file |
| 282 |
} |
| 283 |
|
| 284 |
## |
| 285 |
## parse the manpages in a section of the docs (split by |
| 286 |
## package) and construct formatted manpages |
| 287 |
## |
| 288 |
foreach arg $args { |
| 289 |
if {[llength $arg]} { |
| 290 |
make-manpage-section $html $arg |
| 291 |
} |
| 292 |
} |
| 293 |
|
| 294 |
## |
| 295 |
## build the keyword index. |
| 296 |
## |
| 297 |
if {!$verbose} { |
| 298 |
puts stderr "Assembling index" |
| 299 |
} |
| 300 |
file delete -force -- $html/Keywords |
| 301 |
makedirhier $html/Keywords |
| 302 |
set keyfp [open $html/Keywords/[indexfile] w] |
| 303 |
fconfigure $keyfp -translation lf -encoding utf-8 |
| 304 |
puts $keyfp [htmlhead "$tcltkdesc Keywords" "$tcltkdesc Keywords" \ |
| 305 |
$overall_title "../[indexfile]"] |
| 306 |
set letters {A B C D E F G H I J K L M N O P Q R S T U V W X Y Z} |
| 307 |
# Create header first |
| 308 |
set keyheader {} |
| 309 |
foreach a $letters { |
| 310 |
set keys [array names manual "keyword-\[[string totitle $a$a]\]*"] |
| 311 |
if {[llength $keys]} { |
| 312 |
lappend keyheader "<A HREF=\"$a.htm\">$a</A>" |
| 313 |
} else { |
| 314 |
# No keywords for this letter |
| 315 |
lappend keyheader $a |
| 316 |
} |
| 317 |
} |
| 318 |
set keyheader <H3>[join $keyheader " |\n"]</H3> |
| 319 |
puts $keyfp $keyheader |
| 320 |
foreach a $letters { |
| 321 |
set keys [array names manual "keyword-\[[string totitle $a$a]\]*"] |
| 322 |
if {![llength $keys]} { |
| 323 |
continue |
| 324 |
} |
| 325 |
# Per-keyword page |
| 326 |
set afp [open $html/Keywords/$a.htm w] |
| 327 |
fconfigure $afp -translation lf -encoding utf-8 |
| 328 |
puts $afp [htmlhead "$tcltkdesc Keywords - $a" \ |
| 329 |
"$tcltkdesc Keywords - $a" \ |
| 330 |
$overall_title "../[indexfile]"] |
| 331 |
puts $afp $keyheader |
| 332 |
puts $afp "<DL class=\"keylist\">" |
| 333 |
foreach k [lsort -dictionary $keys] { |
| 334 |
set k [string range $k 8 end] |
| 335 |
puts $afp "<DT><A NAME=\"$k\">$k</A></DT>" |
| 336 |
puts $afp "<DD>" |
| 337 |
set refs {} |
| 338 |
foreach man $manual(keyword-$k) { |
| 339 |
set name [lindex $man 0] |
| 340 |
set file [lindex $man 1] |
| 341 |
if {[info exists manual(tooltip-$file)]} { |
| 342 |
set tooltip $manual(tooltip-$file) |
| 343 |
if {[string match {*[<>""]*} $tooltip]} { |
| 344 |
manerror "bad tooltip for $file: \"$tooltip\"" |
| 345 |
} |
| 346 |
lappend refs "<A HREF=\"../$file\" TITLE=\"$tooltip\">$name</A>" |
| 347 |
} else { |
| 348 |
lappend refs "<A HREF=\"../$file\">$name</A>" |
| 349 |
} |
| 350 |
} |
| 351 |
puts $afp "[join $refs {, }]</DD>" |
| 352 |
} |
| 353 |
puts $afp "</DL>" |
| 354 |
# insert merged copyrights |
| 355 |
puts $afp [copyout $manual(merge-copyrights)] |
| 356 |
puts $afp "</BODY></HTML>" |
| 357 |
close $afp |
| 358 |
} |
| 359 |
# insert merged copyrights |
| 360 |
puts $keyfp [copyout $manual(merge-copyrights)] |
| 361 |
puts $keyfp "</BODY></HTML>" |
| 362 |
close $keyfp |
| 363 |
|
| 364 |
## |
| 365 |
## finish off short table of contents |
| 366 |
## |
| 367 |
puts $manual(short-toc-fp) "<DT><A HREF=\"Keywords/[indexfile]\">Keywords</A><DD>The keywords from the $tcltkdesc man pages." |
| 368 |
puts $manual(short-toc-fp) "</DL>" |
| 369 |
# insert merged copyrights |
| 370 |
puts $manual(short-toc-fp) [copyout $manual(merge-copyrights)] |
| 371 |
puts $manual(short-toc-fp) "</BODY></HTML>" |
| 372 |
close $manual(short-toc-fp) |
| 373 |
|
| 374 |
## |
| 375 |
## output man pages |
| 376 |
## |
| 377 |
unset manual(section) |
| 378 |
if {!$verbose} { |
| 379 |
puts stderr "Rescanning [llength $manual(all-pages)] pages to build cross links and write out" |
| 380 |
} |
| 381 |
foreach path $manual(all-pages) wing_name $manual(all-page-domains) { |
| 382 |
set manual(wing-file) [file dirname $path] |
| 383 |
set manual(tail) [file tail $path] |
| 384 |
set manual(name) [file root $manual(tail)] |
| 385 |
try { |
| 386 |
set text $manual(output-$manual(wing-file)-$manual(name)) |
| 387 |
set ntext 0 |
| 388 |
foreach item $text { |
| 389 |
incr ntext [llength [split $item \n]] |
| 390 |
incr ntext |
| 391 |
} |
| 392 |
set toc $manual(toc-$manual(wing-file)-$manual(name)) |
| 393 |
set ntoc 0 |
| 394 |
foreach item $toc { |
| 395 |
incr ntoc [llength [split $item \n]] |
| 396 |
incr ntoc |
| 397 |
} |
| 398 |
if {$verbose} { |
| 399 |
puts stderr "rescanning page $manual(name) $ntoc/$ntext" |
| 400 |
} else { |
| 401 |
puts -nonewline stderr . |
| 402 |
} |
| 403 |
set outfd [open $html/$manual(wing-file)/$manual(name).htm w] |
| 404 |
fconfigure $outfd -translation lf -encoding utf-8 |
| 405 |
puts $outfd [htmlhead "$manual($manual(wing-file)-$manual(name)-title)" \ |
| 406 |
$manual(name) $wing_name "[indexfile]" \ |
| 407 |
$overall_title "../[indexfile]"] |
| 408 |
if {($ntext > 60) && ($ntoc > 32)} { |
| 409 |
foreach item $toc { |
| 410 |
puts $outfd $item |
| 411 |
} |
| 412 |
} elseif {$manual(name) in $forced_index_pages} { |
| 413 |
if {!$verbose} {puts stderr ""} |
| 414 |
manerror "forcing index generation" |
| 415 |
foreach item $toc { |
| 416 |
puts $outfd $item |
| 417 |
} |
| 418 |
} |
| 419 |
foreach item $text { |
| 420 |
puts $outfd [insert-cross-references $item] |
| 421 |
} |
| 422 |
puts $outfd "</BODY></HTML>" |
| 423 |
} on error msg { |
| 424 |
if {$verbose} { |
| 425 |
puts stderr $msg |
| 426 |
} else { |
| 427 |
puts stderr "\nError when processing $manual(name): $msg" |
| 428 |
} |
| 429 |
} finally { |
| 430 |
catch {close $outfd} |
| 431 |
} |
| 432 |
} |
| 433 |
if {!$verbose} { |
| 434 |
puts stderr "\nDone" |
| 435 |
} |
| 436 |
return {} |
| 437 |
} |
| 438 |
|
| 439 |
## |
| 440 |
## Helper for assembling the descriptions of base packages (i.e., Tcl and Tk). |
| 441 |
## |
| 442 |
proc plus-base {var root glob name dir desc} { |
| 443 |
global tcltkdir |
| 444 |
if {$var} { |
| 445 |
if {[file exists $tcltkdir/$root/README.md]} { |
| 446 |
set f [open $tcltkdir/$root/README.md] |
| 447 |
fconfigure $f -encoding utf-8 |
| 448 |
set d [read $f] |
| 449 |
close $f |
| 450 |
if {[regexp {This is the \*\*\w+ (\S+)\*\* source distribution} $d -> version]} { |
| 451 |
append name ", version $version" |
| 452 |
} |
| 453 |
} |
| 454 |
set glob $root/$glob |
| 455 |
return [list $tcltkdir/$glob $name $dir $desc] |
| 456 |
} |
| 457 |
} |
| 458 |
|
| 459 |
## |
| 460 |
## Helper for assembling the descriptions of contributed packages. |
| 461 |
## |
| 462 |
proc plus-pkgs {type args} { |
| 463 |
global build_tcl tcltkdir tcldir |
| 464 |
if {$type ni {n 3}} { |
| 465 |
error "unknown type \"$type\": must be 3 or n" |
| 466 |
} |
| 467 |
if {!$build_tcl} return |
| 468 |
set result {} |
| 469 |
set pkgsdir $tcltkdir/$tcldir/pkgs |
| 470 |
foreach {dir name version} $args { |
| 471 |
set globpat $pkgsdir/$dir/doc/*.$type |
| 472 |
if {![llength [glob -type f -nocomplain $globpat]]} { |
| 473 |
# Fallback for manpages generated using doctools |
| 474 |
set globpat $pkgsdir/$dir/doc/man/*.$type |
| 475 |
if {![llength [glob -type f -nocomplain $globpat]]} { |
| 476 |
continue |
| 477 |
} |
| 478 |
} |
| 479 |
set dir [string trimright $dir "0123456789-."] |
| 480 |
switch $type { |
| 481 |
n { |
| 482 |
set title "$name Package Commands" |
| 483 |
if {$version ne ""} { |
| 484 |
append title ", version $version" |
| 485 |
} |
| 486 |
set dir [string totitle $dir]Cmd |
| 487 |
set desc \ |
| 488 |
"The additional commands provided by the $name package." |
| 489 |
} |
| 490 |
3 { |
| 491 |
set title "$name Package C API" |
| 492 |
if {$version ne ""} { |
| 493 |
append title ", version $version" |
| 494 |
} |
| 495 |
set dir [string totitle $dir]Lib |
| 496 |
set desc \ |
| 497 |
"The additional C functions provided by the $name package." |
| 498 |
} |
| 499 |
} |
| 500 |
lappend result [list $globpat $title $dir $desc] |
| 501 |
} |
| 502 |
return $result |
| 503 |
} |
| 504 |
|
| 505 |
## |
| 506 |
## Set up some special cases. It would be nice if we didn't have them, |
| 507 |
## but we do... |
| 508 |
## |
| 509 |
set excluded_pages {case menubar pack-old} |
| 510 |
set forced_index_pages {GetDash} |
| 511 |
set process_first_patterns {*/ttk_widget.n */options.n} |
| 512 |
set ensemble_commands { |
| 513 |
after array binary chan clock dde dict encoding file history info interp |
| 514 |
memory namespace package registry self string trace update zlib |
| 515 |
clipboard console font grab grid image option pack place selection tk |
| 516 |
tkwait ttk::style winfo wm itcl::delete itcl::find itcl::is |
| 517 |
} |
| 518 |
array set remap_link_target { |
| 519 |
stdin Tcl_GetStdChannel |
| 520 |
stdout Tcl_GetStdChannel |
| 521 |
stderr Tcl_GetStdChannel |
| 522 |
style ttk::style |
| 523 |
{style map} ttk::style |
| 524 |
{tk busy} busy |
| 525 |
library auto_execok |
| 526 |
safe-tcl safe |
| 527 |
tclvars env |
| 528 |
tcl_break catch |
| 529 |
tcl_continue catch |
| 530 |
tcl_error catch |
| 531 |
tcl_ok catch |
| 532 |
tcl_return catch |
| 533 |
int() mathfunc |
| 534 |
wide() mathfunc |
| 535 |
packagens pkg::create |
| 536 |
pkgMkIndex pkg_mkIndex |
| 537 |
pkg_mkIndex pkg_mkIndex |
| 538 |
Tcl_Obj Tcl_NewObj |
| 539 |
Tcl_ObjType Tcl_RegisterObjType |
| 540 |
Tcl_OpenFileChannelProc Tcl_FSOpenFileChannel |
| 541 |
errorinfo env |
| 542 |
errorcode env |
| 543 |
tcl_pkgpath env |
| 544 |
Tcl_Command Tcl_CreateObjCommand |
| 545 |
Tcl_CmdProc Tcl_CreateObjCommand |
| 546 |
Tcl_CmdDeleteProc Tcl_CreateObjCommand |
| 547 |
Tcl_ObjCmdProc Tcl_CreateObjCommand |
| 548 |
Tcl_Channel Tcl_OpenFileChannel |
| 549 |
Tcl_WideInt Tcl_NewIntObj |
| 550 |
Tcl_ChannelType Tcl_CreateChannel |
| 551 |
Tcl_DString Tcl_DStringInit |
| 552 |
Tcl_Namespace Tcl_AppendExportList |
| 553 |
Tcl_Object Tcl_NewObjectInstance |
| 554 |
Tcl_Class Tcl_GetObjectAsClass |
| 555 |
Tcl_Event Tcl_QueueEvent |
| 556 |
Tcl_Time Tcl_GetTime |
| 557 |
Tcl_ThreadId Tcl_CreateThread |
| 558 |
Tk_Window Tk_WindowId |
| 559 |
Tk_3DBorder Tk_Get3DBorder |
| 560 |
Tk_Anchor Tk_GetAnchor |
| 561 |
Tk_Cursor Tk_GetCursor |
| 562 |
Tk_Dash Tk_GetDash |
| 563 |
Tk_Font Tk_GetFont |
| 564 |
Tk_Image Tk_GetImage |
| 565 |
Tk_ImageMaster Tk_GetImage |
| 566 |
Tk_ImageModel Tk_GetImage |
| 567 |
Tk_ItemType Tk_CreateItemType |
| 568 |
Tk_Justify Tk_GetJustify |
| 569 |
Ttk_Theme Ttk_GetTheme |
| 570 |
} |
| 571 |
array set exclude_refs_map { |
| 572 |
bind.n {button destroy option} |
| 573 |
clock.n {next} |
| 574 |
history.n {exec} |
| 575 |
next.n {unknown} |
| 576 |
zlib.n {binary close filename text} |
| 577 |
canvas.n {bitmap text} |
| 578 |
console.n {eval} |
| 579 |
checkbutton.n {image} |
| 580 |
clipboard.n {string} |
| 581 |
entry.n {string} |
| 582 |
event.n {return} |
| 583 |
font.n {menu} |
| 584 |
getOpenFile.n {file open text} |
| 585 |
grab.n {global} |
| 586 |
interp.n {time} |
| 587 |
menu.n {checkbutton radiobutton} |
| 588 |
messageBox.n {error info} |
| 589 |
options.n {bitmap image set} |
| 590 |
radiobutton.n {image} |
| 591 |
safe.n {join split} |
| 592 |
scale.n {label variable} |
| 593 |
scrollbar.n {set} |
| 594 |
selection.n {string} |
| 595 |
tcltest.n {error} |
| 596 |
text.n {bind image lower raise} |
| 597 |
tkvars.n {tk} |
| 598 |
tkwait.n {variable} |
| 599 |
tm.n {exec} |
| 600 |
ttk_checkbutton.n {variable} |
| 601 |
ttk_combobox.n {selection} |
| 602 |
ttk_entry.n {focus variable} |
| 603 |
ttk_intro.n {focus text} |
| 604 |
ttk_label.n {font text} |
| 605 |
ttk_labelframe.n {text} |
| 606 |
ttk_menubutton.n {flush} |
| 607 |
ttk_notebook.n {image text} |
| 608 |
ttk_progressbar.n {variable} |
| 609 |
ttk_radiobutton.n {variable} |
| 610 |
ttk_scale.n {variable} |
| 611 |
ttk_scrollbar.n {set} |
| 612 |
ttk_spinbox.n {format} |
| 613 |
ttk_treeview.n {text open} |
| 614 |
ttk_widget.n {image text variable} |
| 615 |
TclZlib.3 {binary flush filename text} |
| 616 |
} |
| 617 |
array set exclude_when_followed_by_map { |
| 618 |
canvas.n { |
| 619 |
bind widget |
| 620 |
focus widget |
| 621 |
image are |
| 622 |
lower widget |
| 623 |
raise widget |
| 624 |
} |
| 625 |
selection.n { |
| 626 |
clipboard selection |
| 627 |
clipboard ; |
| 628 |
} |
| 629 |
ttk_image.n { |
| 630 |
image imageSpec |
| 631 |
} |
| 632 |
fontchooser.n { |
| 633 |
tk fontchooser |
| 634 |
} |
| 635 |
} |
| 636 |
|
| 637 |
try { |
| 638 |
# Parse what the user told us to do |
| 639 |
parse_command_line |
| 640 |
|
| 641 |
# Some strings depend on what options are specified |
| 642 |
set tcltkdesc ""; set cmdesc ""; set appdir "" |
| 643 |
if {$build_tcl} { |
| 644 |
append tcltkdesc "Tcl" |
| 645 |
append cmdesc "Tcl" |
| 646 |
append appdir "$tcldir" |
| 647 |
} |
| 648 |
if {$build_tcl && $build_tk} { |
| 649 |
append tcltkdesc "/" |
| 650 |
append cmdesc " and " |
| 651 |
append appdir "," |
| 652 |
} |
| 653 |
if {$build_tk} { |
| 654 |
append tcltkdesc "Tk" |
| 655 |
append cmdesc "Tk" |
| 656 |
append appdir "$tkdir" |
| 657 |
} |
| 658 |
|
| 659 |
apply {{} { |
| 660 |
global packageBuildList tcltkdir tcldir build_tcl |
| 661 |
|
| 662 |
# When building docs for Tcl, try to build docs for bundled packages too |
| 663 |
set packageBuildList {} |
| 664 |
if {$build_tcl} { |
| 665 |
set pkgsDir [file join $tcltkdir $tcldir pkgs] |
| 666 |
set subdirs [glob -nocomplain -types d -tails -directory $pkgsDir *] |
| 667 |
|
| 668 |
foreach dir [lsort $subdirs] { |
| 669 |
# Parse the subdir name into (name, version) as fallback... |
| 670 |
set description [split $dir -] |
| 671 |
if {2 != [llength $description]} { |
| 672 |
regexp {([^0-9]*)(.*)} $dir -> n v |
| 673 |
set description [list $n $v] |
| 674 |
} |
| 675 |
|
| 676 |
# ... but try to extract (name, version) from subdir contents |
| 677 |
try { |
| 678 |
try { |
| 679 |
set f [open [file join $pkgsDir $dir configure.in]] |
| 680 |
} trap {POSIX ENOENT} {} { |
| 681 |
set f [open [file join $pkgsDir $dir configure.ac]] |
| 682 |
} |
| 683 |
fconfigure $f -encoding utf-8 |
| 684 |
foreach line [split [read $f] \n] { |
| 685 |
if {2 == [scan $line \ |
| 686 |
{ AC_INIT ( [%[^]]] , [%[^]]] ) } n v]} { |
| 687 |
set description [list $n $v] |
| 688 |
break |
| 689 |
} |
| 690 |
} |
| 691 |
} on error {} { |
| 692 |
puts "package folder without package ignored: $dir" |
| 693 |
continue |
| 694 |
} finally { |
| 695 |
catch {close $f; unset f} |
| 696 |
} |
| 697 |
|
| 698 |
if {[file exists [file join $pkgsDir $dir configure]]} { |
| 699 |
# Looks like a package, record our best extraction attempt |
| 700 |
lappend packageBuildList $dir {*}$description |
| 701 |
} |
| 702 |
} |
| 703 |
} |
| 704 |
|
| 705 |
# Get the list of packages to try, and what their human-readable names |
| 706 |
# are. Note that the package directory list should be version-less. |
| 707 |
try { |
| 708 |
set packageDirNameMap {} |
| 709 |
if {$build_tcl} { |
| 710 |
set f [open $tcltkdir/$tcldir/pkgs/package.list.txt] |
| 711 |
fconfigure $f -encoding utf-8 |
| 712 |
try { |
| 713 |
foreach line [split [read $f] \n] { |
| 714 |
if {[string trim $line] eq ""} continue |
| 715 |
if {[string match #* $line]} continue |
| 716 |
lassign $line dir name |
| 717 |
dict append packageDirNameMap [string tolower $dir] $name |
| 718 |
dict append packageDirNameMap [string toupper $dir] $name |
| 719 |
dict append packageDirNameMap [string totitle $dir] $name |
| 720 |
} |
| 721 |
} finally { |
| 722 |
close $f |
| 723 |
} |
| 724 |
} |
| 725 |
} trap {POSIX ENOENT} {} { |
| 726 |
set packageDirNameMap { |
| 727 |
itcl {[incr Tcl]} |
| 728 |
tdbc {TDBC} |
| 729 |
thread Thread |
| 730 |
} |
| 731 |
} |
| 732 |
|
| 733 |
# Convert to human readable names, if applicable |
| 734 |
for {set idx 0} {$idx < [llength $packageBuildList]} {incr idx 3} { |
| 735 |
lassign [lrange $packageBuildList $idx $idx+2] d n v |
| 736 |
if {[dict exists $packageDirNameMap $n]} { |
| 737 |
lset packageBuildList $idx+1 [dict get $packageDirNameMap $n] |
| 738 |
} |
| 739 |
} |
| 740 |
}} |
| 741 |
|
| 742 |
# |
| 743 |
# Invoke the scraper/converter engine. |
| 744 |
# |
| 745 |
make-man-pages $webdir \ |
| 746 |
[list $tcltkdir/{$appdir}/doc/*.1 "$tcltkdesc Applications" UserCmd \ |
| 747 |
"The interpreters which implement $cmdesc."] \ |
| 748 |
[plus-base $build_tcl $tcldir doc/*.n {Tcl Commands} TclCmd \ |
| 749 |
"The commands which the <B>tclsh</B> interpreter implements."] \ |
| 750 |
[plus-base $build_tk $tkdir doc/*.n {Tk Commands} TkCmd \ |
| 751 |
"The additional commands which the <B>wish</B> interpreter implements."] \ |
| 752 |
{*}[plus-pkgs n {*}$packageBuildList] \ |
| 753 |
[plus-base $build_tcl $tcldir doc/*.3 {Tcl C API} TclLib \ |
| 754 |
"The C functions which a Tcl extended C program may use."] \ |
| 755 |
[plus-base $build_tk $tkdir doc/*.3 {Tk C API} TkLib \ |
| 756 |
"The additional C functions which a Tk extended C program may use."] \ |
| 757 |
{*}[plus-pkgs 3 {*}$packageBuildList] |
| 758 |
} on error {msg opts} { |
| 759 |
# On failure make sure we show what went wrong. We're not supposed |
| 760 |
# to get here though; it represents a bug in the script. |
| 761 |
puts $msg\n[dict get $opts -errorinfo] |
| 762 |
exit 1 |
| 763 |
} |
| 764 |
|
| 765 |
# Local-Variables: |
| 766 |
# mode: tcl |
| 767 |
# End: |