#
# [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 XML.
#
# This conversion is for standalone manpages ...
#
################################################################
proc here {} [list return [file dirname [info script]]]
source [file join [here] manpage.api] ; # api, defines all required commands with errors.
source [file join [here] memchan] ; # site pages policy and memchan configuration
proc state {} [list return [file join [file dirname [state]] .. htdocs state]]
# Called before the first pass
proc init_hook {} {setpasses 2}
# Called before the first output.
proc begin_hook {} {
# Reset the syn flag
global state
set state(syn) 0
set state(req) 0
return
}
# Called after the last output.
proc end_hook {} {}
################################################################
## Backend for *roff markup
proc manpage_begin {command section version module shortdesc description} {
set hdr ""
append hdr "[ht_comment {}]\n"
append hdr "[ht_comment {Copyright (c) 2000 Andreas Kupries}]\n"
append hdr "[ht_comment {All right reserved}]\n"
append hdr "[ht_comment {}]\n"
append hdr "[ht_comment "CVS: \$Id\$ $command.$section"]\n"
append hdr "[ht_comment {}]\n"
append hdr [page_begin mem/mp/$command][nav_link [mem/sf/txt]]
[site_xref]
[mp_xref]
append hdr [page_content]
append hdr "
$module $version -- [string trimleft $command :]($section)
\n"
append hdr "[section NAME]\n"
append hdr "[para] $command - $description"
return $hdr
}
proc manpage_end {} {return [page_end]}
proc section {name} {return "$name
"}
proc para {} {return }
global state
array set state {req 0 syn 0 call {}}
proc require {pkg {version {}}} {
global state
set state(req) 1
set result "[x_synopsis]package require $pkg"
if {$version != {}} {
append result " $version"
}
append result "
\n"
return $result
}
proc call {cmd args} {
global state
if {[exppass] == 1} {
set oldcolor [bgcolor]
proc bgcolor {} {return lightyellow}
append state(call) "[trtop][td]$cmd [join $args " "]\n"
proc bgcolor {} [list return $oldcolor]
}
return "[lst_item "$cmd [join $args " "]"]"
}
proc description {} {
global state
set result ""
if {$state(call) != {}} {
append result [x_synopsis]
if {$state(req)} {append result
}
append result [btable][tr][td][table]$state(call)\n
}
append result [section DESCRIPTION]
return $result
}
proc x_synopsis {} {
global state
if {!$state(syn)} {
global oldcolor
set state(syn) 1
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 }
definitions {set result }
default {return -code error "Unknown list type $what"}
}
incr list_state(level)
set list_state(l,$list_state(level)) $what
return $result
}
proc list_end {} {
global list_state
set what $list_state(l,$list_state(level))
catch {unset list_state(l,$list_state(level))}
incr list_state(level) -1
switch -exact -- $what {
enum {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
}
################################################################