# -*- tcl -*- # # fmt.html # # (c) 2001 Andreas Kupries # # [expand] definitions to convert a tcl based manpage definition into # a manpage based upon HTML markup. Additional definition files allow # the conversion into nroff and TMML. # ################################################################ proc here {} [list return [file dirname [info script]]] proc this {} [list return [file tail [info script]]] source [file join [here] _common.tcl] ; # Shared code source [file join [here] _html.tcl] ; # HTML basic formatting proc bgcolor {} {return ""} proc border {} {return 0} ################################################################ ## Backend for HTML markup proc manpage_begin {title section version} { if {[mp_pass] == 1} {return} set module [mp_module] set shortdesc [GetDesc mdesc] set description [GetDesc tdesc] set hdr "" append hdr "$title - $shortdesc \n" append hdr "[ht_comment "Generated from [mp_file] by tcllib/doctools/mpexpand with [this]"]\n" append hdr "[ht_comment "Copyright (c) [clock format [clock seconds] -format %Y] $::tcl_platform(user)"]\n" append hdr "[ht_comment {All rights reserved}]\n" append hdr "[ht_comment "CVS: \$Id\$ $title.$section"]\n" append hdr "\n" append hdr "

[string trimleft $title :]($section) $version $module \"$shortdesc\"

\n" append hdr "[section NAME]\n" append hdr "[para] $title - $description" return $hdr } proc moddesc {desc} { if {[mp_pass] == 2} {return} SetDesc mdesc $desc return } proc titledesc {desc} { if {[mp_pass] == 2} {return} SetDesc tdesc $desc return } proc manpage_end {} {return } proc section {name} {return "

$name

"} proc para {} {return

} proc require {pkg {version {}}} { Req 1 set result "[x_synopsis]package require $pkg" if {$version != {}} { append result " $version" } append result "
" return $result } proc call {cmd args} { if {[mp_pass] == 1} { AddCall "[trtop][td]$cmd [join $args " "]\n" return } return "[lst_item "$cmd [join $args " "]"]\n" } proc description {} { set result "" if {[GetCall] != {}} { append result [x_synopsis] if {[Req]} {append result
} proc bgcolor {} {return lightyellow} append result [btable][tr][td][table][GetCall]\n proc bgcolor {} {return ""} } append result [section DESCRIPTION] return $result } proc x_synopsis {} { if {![Syn]} { return [section SYNOPSIS]\n } else { return "" } } ################################################################ global list_state array set list_state {level -1} proc list_begin {what} { global list_state switch -exact -- $what { enum {set result

    } bullet {set result
} bullet {set result } definitions {set result } } return $result } proc lst_item {text} {return
$text
} proc bullet {} {return
  • } proc enum {} {return
  • } ################################################################ proc see_also {args} {return "[section {SEE ALSO}]\n[join $args ", "]"} proc keywords {args} {return "[section KEYWORDS]\n[join $args ", "]"} proc nl {} {return
    } proc arg {text} {return $text} proc cmd {text} {return $text} proc emph {text} {return $text} proc strong {text} {return $text} proc opt {text} {return ?$text?} ################################################################ # HTML specific commands proc ht_comment {text} {return ""} ################################################################ proc setx {v string} { upvar $v _ set _ $string return } proc appendx {v string} { upvar $v _ append _ $string return } ################################################################