File: localdoc.tcl

package info (click to toggle)
tcllib 1.20%2Bdfsg-1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 68,064 kB
  • sloc: tcl: 216,842; ansic: 14,250; sh: 2,846; xml: 1,766; yacc: 1,145; pascal: 881; makefile: 107; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (155 lines) | stat: -rw-r--r-- 4,754 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# -*- tcl -*-
# sak::doc - Documentation facilities

package require sak::util
package require sak::doc

namespace eval ::sak::localdoc {}

# ###
# API commands

## ### ### ### ######### ######### #########

proc ::sak::localdoc::usage {} {
    package require sak::help
    puts stdout \n[sak::help::on localdoc]
    exit 1
}

proc ::sak::localdoc::run {} {
    getpackage cmdline          cmdline/cmdline.tcl
    getpackage fileutil         fileutil/fileutil.tcl
    getpackage textutil::repeat textutil/repeat.tcl
    getpackage doctools         doctools/doctools.tcl
    getpackage doctools::toc    doctools/doctoc.tcl
    getpackage doctools::idx    doctools/docidx.tcl
    getpackage dtplite          dtplite/dtplite.tcl

    # Read installation information. Need the list of excluded
    # modules to suppress them here in the doc generation as well.
    global excluded modules apps guide distribution
    set distribution [pwd]
    source support/installation/modules.tcl

    lappend baseconfig -module tcllib
    foreach e $excluded {
	puts "Excluding $e ..."
	lappend baseconfig -exclude */modules/$e/*
    }

    set nav ../../../../home

    puts "Reindex the documentation..."
    sak::doc::imake __dummy__ $excluded
    sak::doc::index __dummy__ $excluded

    puts "Removing old documentation..."
    # Keep the main index around however, manually created, edited,
    # not to be touched
    # TODO: catch errors and restore automatically
    file rename embedded/index.md e_index.md
    file delete -force embedded
    file mkdir embedded/md

    # Put the saved main page back into place, early.
    file rename e_index.md embedded/index.md

    run-idoc-man $baseconfig

    # Note: Might be better to run them separately.
    # Note @: Or we shuffle the results a bit more in the post processing stage.

    set map  {
	.man     .html
	modules/ tcllib/files/modules/
	apps/    tcllib/files/apps/
    }

    set toc  [string map $map [fileutil::cat support/devel/sak/doc/toc.txt]]
    set apps [string map $map [fileutil::cat support/devel/sak/doc/toc_apps.txt]]
    set mods [string map $map [fileutil::cat support/devel/sak/doc/toc_mods.txt]]
    set cats [string map $map [fileutil::cat support/devel/sak/doc/toc_cats.txt]]

    run-idoc-www $baseconfig $toc $nav $cats $mods $apps

    set map  {
	.man     .md
	modules/ tcllib/files/modules/
	apps/    tcllib/files/apps/
    }

    set toc  [string map $map [fileutil::cat support/devel/sak/doc/toc.txt]]
    set apps [string map $map [fileutil::cat support/devel/sak/doc/toc_apps.txt]]
    set mods [string map $map [fileutil::cat support/devel/sak/doc/toc_mods.txt]]
    set cats [string map $map [fileutil::cat support/devel/sak/doc/toc_cats.txt]]

    run-embedded $baseconfig $toc $cats $mods $apps
    return
}

proc ::sak::localdoc::run-idoc-man {baseconfig} {
    file delete -force idoc
    file mkdir idoc/man
    file mkdir idoc/www

    puts "Generating manpages (installation)..."
    set     config $baseconfig
    lappend config -exclude {*/doctools/tests/*}
    lappend config -exclude {*/support/*}
    lappend config -ext n
    lappend config -o idoc/man
    lappend config nroff .

    dtplite::do $config
    return
}

proc ::sak::localdoc::run-idoc-www {baseconfig toc nav cats mods apps} {
    puts "Generating HTML (installation)... Pass 1, draft..."
    set     config $baseconfig
    lappend config -exclude  {*/doctools/tests/*}
    lappend config -exclude  {*/support/*}
    lappend config -toc      $toc
    lappend config -nav      {Tcllib Home} $nav
    lappend config -post+toc Categories    $cats
    lappend config -post+toc Modules       $mods
    lappend config -post+toc Applications  $apps
    lappend config -merge
    lappend config -o idoc/www
    lappend config html .

    dtplite::do $config

    puts "Generating HTML (installation)... Pass 2, resolving cross-references..."
    dtplite::do $config
    return
}

proc ::sak::localdoc::run-embedded {baseconfig toc cats mods apps} {
    puts "Generating Markdown (online)... Pass 1, draft..."
    set     config $baseconfig
    lappend config -exclude  {*/doctools/tests/*}
    lappend config -exclude  {*/support/*}
    lappend config -ext md ;# must be known before nav options
    lappend config -toc      $toc
    lappend config -post+toc Categories    $cats
    lappend config -post+toc Modules       $mods
    lappend config -post+toc Applications  $apps
    lappend config -merge
    lappend config -o embedded/md
    lappend config markdown .

    dtplite::do $config

    puts "Generating Markdown (online)... Pass 2, resolving cross-references..."
    dtplite::do $config
    return
}

# ### ### ### ######### ######### #########

package provide sak::localdoc 1.0

##
# ###