From b883137394973c0812d2f0ee147ddce2d878bb2e Mon Sep 17 00:00:00 2001 From: dkf Date: Thu, 8 Nov 2012 08:22:13 +0000 Subject: Make HTML generator more resilient against problems when generating docs for older versions of Tcl/Tk. --- tools/tcltk-man2html-utils.tcl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/tcltk-man2html-utils.tcl b/tools/tcltk-man2html-utils.tcl index c0c6a75..780cc6b 100644 --- a/tools/tcltk-man2html-utils.tcl +++ b/tools/tcltk-man2html-utils.tcl @@ -943,7 +943,9 @@ proc output-directive {line} { set line [next-text] if {[is-a-directive $line]} { backup-text 1 - output-name [join $names { }] + if {[llength $names]} { + output-name [join $names { }] + } return } lappend names [string trim $line] -- cgit v0.12 From 4c193ca2a19fee2768b0148f7c0c57888257eb54 Mon Sep 17 00:00:00 2001 From: dkf Date: Thu, 8 Nov 2012 10:14:35 +0000 Subject: Added tooltip generation to contents and keywords pages. --- tools/tcltk-man2html-utils.tcl | 21 +++++++++++++++++---- tools/tcltk-man2html.tcl | 29 +++++++++++++++++++++++------ 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/tools/tcltk-man2html-utils.tcl b/tools/tcltk-man2html-utils.tcl index 780cc6b..d02bcb6 100644 --- a/tools/tcltk-man2html-utils.tcl +++ b/tools/tcltk-man2html-utils.tcl @@ -636,6 +636,7 @@ proc output-name {line} { lappend manual(wing-toc) $name lappend manual(name-$name) $manual(wing-file)/$manual(name) } + set manual(tooltip-$manual(wing-file)/$manual(name).htm) $line } ## @@ -1256,7 +1257,11 @@ proc make-manpage-section {outputDir sectionDescriptor} { # whistle puts stderr "scanning section $manual(wing-name)" # put the entry for this section into the short table of contents - puts $manual(short-toc-fp) "
$manual(wing-name)
$manual(wing-description)
" + if {[regexp {^(.+), version (.+)$} $manual(wing-name) -> name version]} { + puts $manual(short-toc-fp) "
$name
$manual(wing-description)
" + } else { + puts $manual(short-toc-fp) "
$manual(wing-name)
$manual(wing-description)
" + } # initialize the wing table of contents puts $manual(wing-toc-fp) [htmlhead $manual(wing-name) \ $manual(wing-name) $overall_title "../[indexfile]"] @@ -1331,7 +1336,7 @@ proc make-manpage-section {outputDir sectionDescriptor} { } switch -exact -- $code { .if - .nr - .ti - .in - .ie - .el - - .ad - .na - .so - .ne - .AS - .VE - .VS - . { + .ad - .na - .so - .ne - .AS - .HS - .VE - .VS - . { # ignore continue } @@ -1567,8 +1572,16 @@ proc make-manpage-section {outputDir sectionDescriptor} { set tail [lindex $tail [expr {[llength $tail]-1}]] } set tail [file tail $tail] - append rows([expr {$n%$nrows}]) \ - " $name " + if {[info exists manual(tooltip-$manual(wing-file)/$tail.htm)]} { + set tooltip $manual(tooltip-$manual(wing-file)/$tail.htm) + set tooltip [string map {[ {\[} ] {\]} $ {\$} \\ \\\\} $tooltip] + regsub {^[^-]+-\s*(.)} $tooltip {[string totitle \1]} tooltip + append rows([expr {$n%$nrows}]) \ + " $name " + } else { + append rows([expr {$n%$nrows}]) \ + " $name " + } incr n } puts $manual(wing-toc-fp) diff --git a/tools/tcltk-man2html.tcl b/tools/tcltk-man2html.tcl index 585d76a..665a1d4 100755 --- a/tools/tcltk-man2html.tcl +++ b/tools/tcltk-man2html.tcl @@ -328,7 +328,15 @@ proc make-man-pages {html args} { foreach man $manual(keyword-$k) { set name [lindex $man 0] set file [lindex $man 1] - lappend refs "$name" + if {[info exists manual(tooltip-$file)]} { + set tooltip $manual(tooltip-$file) + if {[string match {*[<>""]*} $tooltip]} { + manerror "bad tooltip for $file: \"$tooltip\"" + } + lappend refs "$name" + } else { + lappend refs "$name" + } } puts $afp "[join $refs {, }]" } @@ -420,9 +428,18 @@ proc make-man-pages {html args} { ## ## Helper for assembling the descriptions of base packages (i.e., Tcl and Tk). ## -proc plus-base {var glob name dir desc} { +proc plus-base {var root glob name dir desc} { global tcltkdir if {$var} { + if {[file exists $tcltkdir/$root/README]} { + set f [open $tcltkdir/$root/README] + set d [read $f] + close $f + if {[regexp {This is the \w+ (\S+) source distribution} $d -> version]} { + append name ", version $version" + } + } + set glob $root/$glob return [list $tcltkdir/$glob $name $dir $desc] } } @@ -655,14 +672,14 @@ try { make-man-pages $webdir \ [list $tcltkdir/{$appdir}/doc/*.1 "$tcltkdesc Applications" UserCmd \ "The interpreters which implement $cmdesc."] \ - [plus-base $build_tcl $tcldir/doc/*.n {Tcl Commands} TclCmd \ + [plus-base $build_tcl $tcldir doc/*.n {Tcl Commands} TclCmd \ "The commands which the tclsh interpreter implements."] \ - [plus-base $build_tk $tkdir/doc/*.n {Tk Commands} TkCmd \ + [plus-base $build_tk $tkdir doc/*.n {Tk Commands} TkCmd \ "The additional commands which the wish interpreter implements."] \ {*}[plus-pkgs n {*}$packageDirNameMap] \ - [plus-base $build_tcl $tcldir/doc/*.3 {Tcl C API} TclLib \ + [plus-base $build_tcl $tcldir doc/*.3 {Tcl C API} TclLib \ "The C functions which a Tcl extended C program may use."] \ - [plus-base $build_tk $tkdir/doc/*.3 {Tk C API} TkLib \ + [plus-base $build_tk $tkdir doc/*.3 {Tk C API} TkLib \ "The additional C functions which a Tk extended C program may use."] \ {*}[plus-pkgs 3 {*}$packageDirNameMap] } on error {msg opts} { -- cgit v0.12