File: format.tcl

package info (click to toggle)
tclthread 1%3A2.6.7-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 1,552 kB
  • sloc: ansic: 7,589; tcl: 1,642; sh: 393; makefile: 113; cpp: 31
file content (35 lines) | stat: -rw-r--r-- 821 bytes parent folder | download | duplicates (8)
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
#!/usr/local/bin/tclsh
set mydir [file dirname [info script]]
lappend auto_path /usr/local/lib
package req doctools
doctools::new dt
set wd [pwd]
cd $mydir
file rename html htm
set code [catch {
    set f [open man.macros]
    set m [read $f]
    close $f
    foreach file [glob -nocomplain *.man] {
        set xx [file root $file]
        set f [open $xx.man]
        set t [read $f]
        close $f
        foreach {fmt ext dir} {nroff n man html html htm} {
            dt configure -format $fmt
            set o [dt format $t]
            set f [open $dir/$xx.$ext w]
            if {$fmt == "nroff"} {
                set o [string map [list {.so man.macros} $m] $o]
            }
            puts $f $o
            close $f
        }
    }
} err]
file rename htm html
cd $wd
if {$code} {
    error $err
}
exit 0