File: format.tcl

package info (click to toggle)
tclthread 1%3A2.8.11-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,764 kB
  • sloc: ansic: 8,328; tcl: 1,710; sh: 407; makefile: 83
file content (35 lines) | stat: -rw-r--r-- 716 bytes parent folder | download | duplicates (4)
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