#!/usr/bin/tclsh # # This script processes raw documentation source text into its final form # for display. The processing actions are described below. # # Invoke this command as follows: # # tclsh wrap.tcl $(DOC) $(SRC) $(DEST) source1.in source2.in ... # # The $(DOC) and $(SRC) values are the names of directories containing # the documentation source and program source. $(DEST) is the name of # of the directory where generated HTML is written. sourceN.in is the # input file to be processed. The output is sourceN.html in the # $(DEST) directory. # # Changes made to the source files: # # * An appropriate header (containing the SQLite logo and standard # menu bar) is prepended to the file. # # * Any
} if {1} { putsin4 $fd {} } if {1} { putsin4 $fd { |
|
*** DRAFT ***
} } else { set hd(footer) {} } } else { set hd(enable-main) $saved_enable } } # Insert a bubble syntax diagram into the output. # proc BubbleDiagram {name {anonymous_flag 0}} { global hd #if {!$anonymous_flag} { # hd_resolve "\[$name:\]
" set alt "alt=\"syntax diagram $name\"" if {$hd(enable-main)} { puts $hd(main) "\n\ \n\" } if {$hd(enable-aux)} { puts $hd(aux) "
\n\ \n\" } } proc HiddenBubbleDiagram {name} { global hd set alt "alt=\"syntax diagram $name\"" hd_resolve "
\[$name:\] " if {$hd(enable-main)} { set a [hd_id] set b [hd_id] puts $hd(main) \ "\
\n\ " } if {$hd(enable-aux)} { set a [hd_id] set b [hd_id] puts $hd(aux) \ "\ \n\ " } } proc RecursiveBubbleDiagram_helper {class name openlist exclude} { global hd syntax_linkage set alt "alt=\"syntax diagram $name\"" hd_resolve "\[$name:\]\n" set a [hd_id] set b [hd_id] set openflag 0 set open2 {} foreach x $openlist { if {$x==$name} { set openflag 1 } else { lappend open2 $x } } if {$openflag} { puts $hd($class) \ "
\n\\n\ " } else { puts $hd($class) \ "\n\" } proc RecursiveBubbleDiagram {args} { global hd set show 1 set a2 {} foreach name $args { if {$name=="--initially-hidden"} { set show 0 } else { lappend a2 $name } } if {$show} { set showlist $a2 } else { set showlist {} } set name [lindex $a2 0] if {$hd(enable-main)} { RecursiveBubbleDiagram_helper main $name $showlist $name } if {$hd(enable-aux)} { RecursiveBubbleDiagram_helper aux $name $showlist $name } } # Insert a See Also line for related bubble # Record a requirement. This procedure is active only for the first # pass. This procedure becomes a no-op for the second pass. During # the second pass, requirements listing report generators can use the # data accumulated during the first pass to construct their reports. # # If the "verbatim" argument is true, then the requirement text is # rendered as is. In other words, the requirement text is assumed to # be valid HTML with all hyperlinks already resolved. If the "verbatim" # argument is false (the default) then the requirement text is rendered # using hd_render which will find an expand hyperlinks within the text. # # The "comment" argument is non-binding commentary and explanation that # accompanies the requirement. # proc hd_requirement {id text derivedfrom comment} { global ALLREQ ALLREQ_DERIVEDFROM ALLREQ_COM if {[info exists ALLREQ($id)]} { puts stderr "duplicate requirement label: $id" } set ALLREQ_DERIVEDFROM($id) $derivedfrom set ALLREQ($id) $text set ALLREQ_COM($id) $comment } # Read a block of requirements from an ASCII text file. Store the # information obtained in a global variable named by the second parameter. # proc hd_read_requirement_file {filename varname} { global hd_req_rdr hd_reset_requirement_reader set in [open $filename] while {![eof $in]} { set line [gets $in] if {[regexp {^(HLR|UNDEF|SYSREQ) +([LHSU]\d+) *(.*)} $line all type rn df]} { hd_add_one_requirement $varname set hd_req_rdr(rn) $rn set hd_req_rdr(derived) $df } elseif {[string trim $line]==""} { if {$hd_req_rdr(body)==""} { set hd_req_rdr(body) $hd_req_rdr(comment) set hd_req_rdr(comment) {} } else { append hd_req_rdr(comment) \n } } else { append hd_req_rdr(comment) $line\n } } hd_add_one_requirement $varname close $in } proc hd_reset_requirement_reader {} { global hd_req_rdr set hd_req_rdr(rn) {} set hd_req_rdr(comment) {} set hd_req_rdr(body) {} set hd_req_rdr(derived) {} } proc hd_add_one_requirement {varname} { global hd_req_rdr set rn $hd_req_rdr(rn) if {$rn!=""} { if {$hd_req_rdr(body)==""} { set hd_req_rdr(body) $hd_req_rdr(comment) set hd_req_rdr(comment) {} } set b [string trim $hd_req_rdr(body)] set c [string trim $hd_req_rdr(comment)] set ::${varname}($rn) [list $hd_req_rdr(derived) $b $c] lappend ::${varname}(*) $rn } hd_reset_requirement_reader } # First pass. Process all files. But do not render hyperlinks. # Merely collect keyword information so that hyperlinks can be # correctly rendered on the second pass. # foreach infile [lrange $argv 3 end] { cd $HOMEDIR puts "Processing $infile" set fd [open $infile r] set in [read $fd] close $fd if {[regexp {<(fancy_format|table_of_contents)>} $in]} { set in [addtoc $in] } set title {No Title} regexp {([^\n]*) } $in all title regsub {[^\n]* } $in {} in set outfile [file root [file tail $infile]].html hd_open_main $outfile db eval { INSERT INTO page(filename,pagetitle) VALUES($outfile,$title); } set h(pageid) [db last_insert_rowid] hd_header $title $infile regsub -all {} $in "\175; eval \173" in regsub -all { } $in "\175; hd_puts \173" in eval "hd_puts \173$in\175" cd $::HOMEDIR hd_close_main } # Second pass. Process all files again. This time render hyperlinks # according to the keyword information collected on the first pass. # proc hd_keywords {args} {} rename hd_resolve {} rename hd_resolve_2ndpass hd_resolve proc hd_requirement {args} {} set footertcl [file normalize [file join $::DOC pages footer.tcl]] foreach infile [lrange $argv 3 end] { cd $HOMEDIR puts "Processing $infile" set fd [open $infile r] set in [read $fd] close $fd if {[regexp {<(fancy_format|table_of_contents)>} $in]} { set in [addtoc $in] } set title {No Title} regexp {([^\n]*) } $in all title regsub {[^\n]* } $in {} in set outfile [file root [file tail $infile]].html hd_open_main $outfile hd_header $title $infile regsub -all {} $in "\175; eval \173" in regsub -all { } $in "\175; hd_resolve \173" in eval "hd_resolve \173$in\175" source $footertcl cd $::HOMEDIR hd_close_main } # Generate a document showing the hyperlink keywords and their # targets. # hd_open_main doc_keyword_crossref.html hd_header {Keyword Crossreference} $DOC/wrap.tcl hd_puts "" foreach x [lsort -dict [array names glink]] { set y $glink($x) hd_puts "
" hd_close_main hd_open_main doc_target_crossref.html hd_header {Target Crossreference} $DOC/wrap.tcl hd_puts "- $x - $y
" lappend revglink($y) $x } hd_puts "" foreach y [lsort [array names revglink]] { hd_puts "
" hd_close_main hd_open_main doc_backlink_crossref.html hd_header {Backlink Crossreference} $DOC/wrap.tcl hd_puts "- $y - [lsort $revglink($y)]
" } hd_puts "" foreach kw [lsort -nocase [array names backlink]] { hd_puts "
" hd_close_main hd_open_main doc_pagelink_crossref.html hd_header {Pagelink Crossreference} $DOC/wrap.tcl hd_puts "- $kw -" set prev {} foreach ref [lsort $backlink($kw)] { if {$ref==$prev} continue set prev $ref hd_puts " $ref" } } hd_puts "
Target Page - Which pages reference it.
" hd_puts "Pages matching (news|changes|releaselog|\[0-9]to\[0-9]|^doc_.*_crossref) are skipped.
" hd_puts "" foreach y [lsort [array names revglink]] { regsub {#.*} $y {} y2 foreach kw [lsort $revglink($y)] { if {[info exists backlink($kw)]} { foreach ref [lsort $backlink($kw)] { regsub {#.*} $ref {} ref2 lappend pagelink($y2) $ref2 } } } } foreach y [lsort [array names pagelink]] { if {[regexp {(news|changes|releaselog|[0-9]to[0-9]|^doc_.*_crossref)} $y]} continue hd_puts "
" hd_close_main db eval COMMIT- $y - " set prev {} foreach ref [lsort $pagelink($y)] { if {$ref==$prev} continue if {$ref==$y} continue if {[regexp {(news|changes|releaselog|[0-9]to[0-9]|^doc_.*_crossref)} $ref]} continue hd_puts "$ref " set prev $ref } hd_puts "
" } hd_puts "