1#!/usr/local/bin/tclsh 2set mydir [file dirname [info script]] 3lappend auto_path /usr/local/lib 4package req doctools 5doctools::new dt 6set wd [pwd] 7cd $mydir 8file rename html htm 9set code [catch { 10 set f [open man.macros] 11 set m [read $f] 12 close $f 13 foreach file [glob -nocomplain *.man] { 14 set xx [file root $file] 15 set f [open $xx.man] 16 set t [read $f] 17 close $f 18 foreach {fmt ext dir} {nroff n man html html htm} { 19 dt configure -format $fmt 20 set o [dt format $t] 21 set f [open $dir/$xx.$ext w] 22 if {$fmt == "nroff"} { 23 set o [string map [list {.so man.macros} $m] $o] 24 } 25 puts $f $o 26 close $f 27 } 28 } 29} err] 30file rename htm html 31cd $wd 32if {$code} { 33 error $err 34} 35exit 0 36