doc.tcl

Go to the documentation of this file.
00001 /*  -*- tcl -*-*/
00002 /*  sak::doc - Documentation facilities*/
00003 
00004 package require sak::util
00005 
00006 namespace ::sak::doc {}
00007 
00008 /*  ###*/
00009 /*  API commands*/
00010 
00011 ret  ::sak::doc::validate (type modules) {Gen null  null $modules}
00012 ret  ::sak::doc::html     (type modules) {Gen html  html $modules}
00013 ret  ::sak::doc::nroff    (type modules) {Gen nroff n    $modules}
00014 ret  ::sak::doc::tmml     (type modules) {Gen tmml  tmml $modules}
00015 ret  ::sak::doc::text     (type modules) {Gen text  txt  $modules}
00016 ret  ::sak::doc::wiki     (type modules) {Gen wiki  wiki $modules}
00017 ret  ::sak::doc::latex    (type modules) {Gen latex tex  $modules}
00018 
00019 ret  ::sak::doc::dvi (type modules) {
00020     latex $modules
00021     file mkdir [file join doc dvi]
00022     cd         [file join doc dvi]
00023 
00024     foreach f [lsort -dict [glob -nocomplain ../latex/*.tex]] {
00025 
00026     set target [file rootname [file tail $f]].dvi
00027     if {[file exists $target] 
00028         && [file mtime $target] > [file mtime $f]} {
00029         continue
00030     }
00031 
00032     puts "Gen (dvi): $f"
00033     exec latex $f 1>@ stdout 2>@ stderr
00034     }
00035     cd ../..
00036     return
00037 }
00038 
00039 ret  ::sak::doc::ps (type modules) {
00040     dvi $modules
00041     file mkdir [file join doc ps]
00042     cd         [file join doc ps]
00043     foreach f [lsort -dict [glob -nocomplain ../dvi/*.dvi]] {
00044 
00045     set target [file rootname [file tail $f]].ps
00046     if {[file exists $target] 
00047         && [file mtime $target] > [file mtime $f]} {
00048         continue
00049     }
00050 
00051     puts "Gen (ps): $f"
00052     exec dvips -o $target $f >@ stdout 2>@ stderr
00053     }
00054     cd ../..
00055     return
00056 }
00057 
00058 ret  ::sak::doc::pdf (type modules) {
00059     dvi $modules
00060     file mkdir [file join doc pdf]
00061     cd         [file join doc pdf]
00062     foreach f [lsort -dict [glob -nocomplain ../ps/*.ps]] {
00063 
00064     set target [file rootname [file tail $f]].pdf
00065     if {[file exists $target] 
00066         && [file mtime $target] > [file mtime $f]} {
00067         continue
00068     }
00069 
00070     puts "Gen (pdf): $f"
00071     exec ps2pdf $f $target >@ stdout 2>@ stderr
00072     }
00073     cd ../..
00074     return
00075 }
00076 
00077 ret  ::sak::doc::list (type modules) {
00078     Gen list l $modules
00079     
00080     set FILES [glob -nocomplain doc/list/*.l]
00081     set LIST  [open [file join doc list manpages.tcl] w]
00082 
00083     foreach file $FILES {
00084         set f [open $file r]
00085         puts $LIST [read $f]
00086         close $f
00087     }
00088     close $LIST
00089 
00090     eval file delete -force $FILES
00091     return
00092 }
00093 
00094 /*  ### ### ### ######### ######### #########*/
00095 /*  Implementation*/
00096 
00097 ret  ::sak::doc::Gen (type fmt , type ext , type modules) {
00098     global distribution
00099     global tcl_platform
00100 
00101     getpackage doctools doctools/doctools.tcl
00102 
00103     set null   0 ; if {![string compare $fmt null]} {set null   1}
00104     set hidden 0 ; if {![string compare $fmt desc]} {set hidden 1}
00105 
00106     if {!$null} {
00107     file mkdir [file join doc $fmt]
00108     set prefix "Gen ($fmt)"
00109     } else {
00110     set prefix "Validate  "
00111     }
00112 
00113     foreach m $modules {
00114     set mpath [sak::util::module2path $m]
00115 
00116     ::doctools::new dt \
00117         -format $fmt \
00118         -module $m
00119 
00120     set fl [glob -nocomplain [file join $mpath *.man]]
00121 
00122     if {[llength $fl] == 0} {
00123         dt destroy
00124         continue
00125     }
00126 
00127     foreach f $fl {
00128         if {!$null} {
00129                 set target [file join doc $fmt \
00130                                 [file rootname [file tail $f]].$ext]
00131                 if {[file exists $target] 
00132                     && [file mtime $target] > [file mtime $f]} {
00133                     continue
00134                 }
00135         }
00136         if {!$hidden} {puts "$prefix: $f"}
00137 
00138         dt configure -file $f
00139         if {$null} {
00140         dt configure -deprecated 1
00141         }
00142 
00143         set fail [catch {
00144         set data [dt format [get_input $f]]
00145         } msg]
00146 
00147         set warnings [dt warnings]
00148         if {[llength $warnings] > 0} {
00149         puts stderr [join $warnings \n]
00150         }
00151 
00152         if {$fail} {
00153         puts stderr $msg
00154         continue
00155         }
00156 
00157         if {!$null} {
00158         write_out $target $data
00159         }
00160     }
00161     dt destroy
00162     }
00163 }
00164 
00165 /*  ### ### ### ######### ######### #########*/
00166 
00167 package provide sak::doc 1.0
00168 
00169 /** 
00170  * ###
00171 

Generated on 21 Sep 2010 for Gui by  doxygen 1.6.1