File: format.tcl

package info (click to toggle)
tclthread3 3.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,752 kB
  • sloc: ansic: 8,259; tcl: 1,711; sh: 436; makefile: 38
file content (35 lines) | stat: -rw-r--r-- 716 bytes parent folder | download | duplicates (3)
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