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
#!/bin/env tclsh
set files {
*.tcl
spdx/lib.tcl
ui/*.tcl
db/*.tcl
irc/*.tcl
}
set basedir \
[file normalize \
[file join \
[file dirname \
[dict get [info frame [info frame]] file]] ..]]
foreach dir [list \
[file join $basedir doc doctools gen] \
[file join $basedir doc md]] \
{
file delete -force $dir
file mkdir $dir
}
cd [file join $basedir src]
set files [glob -nocomplain {*}$files]
foreach file $files {
set opath [file join $basedir doc doctools gen $file]
file mkdir [file dirname $opath]
}
file mkdir [file join $basedir doc doctools gen]
exec -- [file join $basedir bin docextract.tcl] -o [file join $basedir doc doctools gen] -all {*}$files
package require doctools
doctools::new .doc
.doc configure -format markdown -ibase [file join $basedir doc doctools]
cd [file join $basedir doc doctools gen]
set to_check .
while {[llength $to_check]} {
set to_check [lassign $to_check cur]
foreach file [glob -directory $cur -types f -nocomplain *.man] {
set ofile [file rootname $file].md
set opath [file join $basedir doc md $ofile]
file mkdir [file dirname $opath]
.doc configure -file $ofile
set ifd [open $file r]
set ofd [open $opath w]
puts $ofd {---
toc: false
---}
puts -nonewline $ofd [.doc format [read $ifd]]
close $ifd
close $ofd
puts $ofile
}
lappend to_check {*}[glob -directory $cur -types d -nocomplain *]
}