Index: modules/dtplite/ChangeLog ================================================================== --- modules/dtplite/ChangeLog +++ modules/dtplite/ChangeLog @@ -1,4 +1,11 @@ +2013-04-04 Andreas Kupries + + * dtplite.man: [Feature 3609342]: Applied Ashok's patch to disable + * dtplite.tcl: the keyword index page when the processed + * pkgIndex.tcl: documentation does not contain keywords, with + modifications. Version bumped to 1.1. + 2013-02-22 Andreas Kupries * New module 'dtplite'. dtplite application-as-package. Index: modules/dtplite/dtplite.man ================================================================== --- modules/dtplite/dtplite.man +++ modules/dtplite/dtplite.man @@ -1,7 +1,7 @@ [comment {-*- tcl -*- doctools manpage}] -[manpage_begin dtplite n 1.0.5] +[manpage_begin dtplite n 1.1] [copyright {2004-2013 Andreas Kupries }] [titledesc {Lightweight DocTools Markup Processor}] [moddesc {Documentation toolbox}] [category {Documentation tools}] [description] Index: modules/dtplite/dtplite.tcl ================================================================== --- modules/dtplite/dtplite.tcl +++ modules/dtplite/dtplite.tcl @@ -1,8 +1,8 @@ # -*- tcl -*- \ # @@ Meta Begin -# Application dtplite 1.0.5 +# Application dtplite 1.1 # Meta platform tcl # Meta summary Lightweight DocTools Processor # Meta description This application is a simple processor # Meta description for documents written in the doctools # Meta description markup language. It covers the most @@ -17,11 +17,11 @@ # Meta require textutil::repeat # Meta author Andreas Kupries # Meta license BSD # @@ Meta End -package provide dtplite 1.0.5 +package provide dtplite 1.1 # dtp lite - Lightweight DocTools Processor # ======== = ============================== # # Use cases @@ -836,10 +836,16 @@ } MetadataGet $files StyleMakeLocal + # Attention, ordering! Ensure that 'kwid' is initialized before + # testing it with 'HaveKeywords' everywhere we configure the links + # showns in the navigation bar. + + set idx [IdxGenerate $module [IdxGet]] + if {$utoc ne {}} { if {[file exists $utoc]} { set utoc [Get $utoc] } TocWrite toc index $utoc } else { TocWrite toc index [TocGenerate [TocGet $module toc]] @@ -849,11 +855,11 @@ foreach item $mtoc { if {[file exists $item]} { set item [Get $item] } TocWrite toc$n index $item incr n } - IdxWrite index toc [IdxGenerate $module [IdxGet]] + IdxWrite index toc $idx dt configure -module $module XrefGet XrefSetup dt FooterSetup dt @@ -863,15 +869,19 @@ Print stdout \t$f set o $out($f) dt configure -file [At $o] -ibase $input/$f - NavbuttonPush {Keyword Index} [Output index] $o + if {[HaveKeywords]} { + NavbuttonPush {Keyword Index} [Output index] $o + } NavbuttonPush {Table Of Contents} [Output toc] $o HeaderSetup dt $o NavbuttonPop - NavbuttonPop + if {[HaveKeywords]} { + NavbuttonPop + } StyleSetup dt $o if {[string equal $format null]} { dt format [Get [Pick $f]] } else { @@ -913,10 +923,16 @@ } MetadataGet $files $module StyleMakeLocal $module + # Attention, ordering! Ensure that 'kwid' is initialized before + # testing it with 'HaveKeywords' everywhere we configure the links + # showns in the navigation bar. + + set idx [IdxGenerate {} [IdxGetSaved index]] + set localtoc [TocGet $module $module/toc] TocWrite $module/toc index [TocGenerate $localtoc] [TocMap $localtoc] if {$utoc ne {}} { if {[file exists $utoc]} { set utoc [Get $utoc] } TocWrite toc index $utoc @@ -928,11 +944,11 @@ foreach item $mtoc { if {[file exists $item]} { set item [Get $item] } TocWrite toc$n index $item incr n } - IdxWrite index toc [IdxGenerate {} [IdxGetSaved index]] + IdxWrite index toc $idx dt configure -module $module XrefGetSaved XrefSetup dt FooterSetup dt @@ -941,18 +957,21 @@ foreach f [lsort -dict $files] { Print stdout \t$f set o $out($f) dt configure -file [At $o] -ibase $input/$f - - NavbuttonPush {Keyword Index} [Output index] $o + if {[HaveKeywords]} { + NavbuttonPush {Keyword Index} [Output index] $o + } NavbuttonPush {Table Of Contents} [Output $module/toc] $o NavbuttonPush {Main Table Of Contents} [Output toc] $o HeaderSetup dt $o NavbuttonPop NavbuttonPop - NavbuttonPop + if {[HaveKeywords]} { + NavbuttonPop + } StyleSetup dt $o if {[string equal $format null]} { dt format [Get [Pick $f]] } else { @@ -1131,14 +1150,17 @@ Write [At .tocdoc] $text set ft [Output $ftoc] doctools::toc::new toc -format $format -file $ft - - NavbuttonPush {Keyword Index} [Output $findex] $ftoc - HeaderSetup toc $ft - NavbuttonPop + if {[HaveKeywords]} { + NavbuttonPush {Keyword Index} [Output $findex] $ftoc + } + HeaderSetup toc $ft + if {[HaveKeywords]} { + NavbuttonPop + } FooterSetup toc StyleSetup toc $ftoc foreach {k v} $map {toc map $k $v} @@ -1257,10 +1279,12 @@ proc ::dtplite::IdxWrite {findex ftoc text} { variable format if {[string equal $format null]} return + if {![HaveKeywords]} return + Write [At .idxdoc] $text set fi [Output $findex] doctools::idx::new idx -format $format -file $fi @@ -1284,10 +1308,18 @@ foreach {symfile label} $item break Max mxf $symfile } return } + +# ### ### ### ######### ######### ######### +## Detect presence of keywords. + +proc ::dtplite::HaveKeywords {} { + variable kwid + array size kwid +} # ### ### ### ######### ######### ######### ## Column sizing proc ::dtplite::Max {v str} { @@ -1577,13 +1609,23 @@ ## Caching the merge result for quicker future access. proc ::dtplite::HeaderSetup {o ref} { variable header variable nav + variable prenav + variable postnav + + # We cannot generate a navigation bar if the output format does + # not support a "header". + if {![in [$o parameters] header]} return - if {[string equal $header ""] && ![llength $nav]} return - if {![in [$o parameters] header]} return + # Do not generate a navigation bar if no content was specified for + # it, at all. + if {![llength $prenav] && + ![llength $postnav] && + ![llength $nav] && + [string equal $header ""]} return $o setparam header [Navbar $nav $ref] return } Index: modules/dtplite/pkgIndex.tcl ================================================================== --- modules/dtplite/pkgIndex.tcl +++ modules/dtplite/pkgIndex.tcl @@ -1,5 +1,5 @@ if {![package vsatisfies [package provide Tcl] 8.2]} { # PRAGMA: returnok return } -package ifneeded dtplite 1.0.5 [list source [file join $dir dtplite.tcl]] +package ifneeded dtplite 1.1 [list source [file join $dir dtplite.tcl]]