Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Markdown: Implemented document cross references, and added refs to the per-page synopses. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | doc-fixup-and-markdown |
Files: | files | file ages | folders |
SHA3-256: |
a8b930a4d3528544605a35093a5ab06e |
User & Date: | aku 2019-03-20 22:57:47.406 |
Context
2019-03-21
| ||
19:50 | Merged localdoc work based on markdown into markdown. check-in: e0d7b4dc8e user: aku tags: doc-fixup-and-markdown | |
2019-03-20
| ||
23:39 | Merge latest work done on markdown generator (tocs, xrefs). check-in: 945be77637 user: aku tags: doc-fixup-and-markdown-localdoc | |
22:57 | Markdown: Implemented document cross references, and added refs to the per-page synopses. check-in: a8b930a4d3 user: aku tags: doc-fixup-and-markdown | |
05:31 | Markdown: Implemented section cross references, per-page TOC. Updated test results. check-in: 78d88166a8 user: aku tags: doc-fixup-and-markdown | |
Changes
Changes to modules/doctools/mpformats/_html.tcl.
︙ | ︙ | |||
109 110 111 112 113 114 115 116 117 118 119 120 121 122 | proc use_bg {} { set c [bgcolor] #puts stderr "using $c" if {$c == {}} {return ""} return bgcolor=$c } proc nbsp {} {return [markup " "]} proc p {} {return [markup <p>]} proc ptop {} {return [markup "<p valign=top>"]} proc td {} {return [markup "<td [use_bg]>"]} proc trtop {} {return [markup "<tr valign=top [use_bg]>"]} proc tr {} {return [markup "<tr [use_bg]>"]} | > | 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | proc use_bg {} { set c [bgcolor] #puts stderr "using $c" if {$c == {}} {return ""} return bgcolor=$c } proc MakeLink {l t} { link $l $t } proc nbsp {} {return [markup " "]} proc p {} {return [markup <p>]} proc ptop {} {return [markup "<p valign=top>"]} proc td {} {return [markup "<td [use_bg]>"]} proc trtop {} {return [markup "<tr valign=top [use_bg]>"]} proc tr {} {return [markup "<tr [use_bg]>"]} |
︙ | ︙ |
Changes to modules/doctools/mpformats/_markdown.tcl.
︙ | ︙ | |||
59 60 61 62 63 64 65 66 67 68 69 70 71 72 | TextTrimLeadingSpace CloseParagraph [Verbatim] } ## # # ## ### ##### ######## ## proc ALink {dst label} { return "\[$label]($dst)" } proc SetAnchor {text {name {}}} { if {$name == {}} { set name [Anchor $text] } return "<a name='$name'></a>$text" } | > > | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | TextTrimLeadingSpace CloseParagraph [Verbatim] } ## # # ## ### ##### ######## ## proc MakeLink {l t} { ALink $t $l } ;# - xref - todo: consolidate proc ALink {dst label} { return "\[$label]($dst)" } proc SetAnchor {text {name {}}} { if {$name == {}} { set name [Anchor $text] } return "<a name='$name'></a>$text" } |
︙ | ︙ |
Added modules/doctools/mpformats/_xref.tcl.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | # -*- tcl -*- ## # Shared code for the management of cross-references between # documents. Origin in HTML. Other user: Markdown. # # Copyright (c) 2001,2019 Andreas Kupries <[email protected]> # Hook: # - MakeLink {label target} - Format specific # - GetXref - Engine parameter access # # ## ### ##### ######## ############# ##################### ## API proc XrefInit {} { global xref foreach item [GetXref] { foreach {pattern fname fragment} $item break set fname_ref [dt_fmap $fname] if {$fragment != {}} {append fname_ref #$fragment} set xref($pattern) $fname_ref } proc XrefInit {} {} return } proc XrefMatch {word args} { global xref foreach ext $args { if {$ext != {}} { if {[info exists xref($ext,$word)]} { return [XrefLink $xref($ext,$word) $word] } } } if {[info exists xref($word)]} { return [XrefLink $xref($word) $word] } # Convert the word to all-lower case and then try again. set lword [string tolower $word] foreach ext $args { if {$ext != {}} { if {[info exists xref($ext,$lword)]} { return [XrefLink $xref($ext,$lword) $word] } } } if {[info exists xref($lword)]} { return [XrefLink $xref($lword) $word] } return $word } proc XrefList {list {ext {}}} { set res [list] foreach w $list {lappend res [XrefMatch $w $ext]} return $res } proc XrefLink {dest label} { # Ensure that the link is properly done relative to this file! set here [LinkHere] set dest [LinkTo $dest $here] if {[string equal $dest [lindex [file split $here] end]]} { # Suppress self-referential links, i.e. links made from the # current file to itself. Note that links to specific parts of # the current file are not suppressed, only exact links. return $label } return [MakeLink $label $dest] } # # ## ### ##### ######## ############# ##################### ## Internals proc LinkHere {} { return [dt_fmap [dt_mainfile]] } proc LinkTo {dest here} { # Ensure that the link is properly done relative to this file! set save $dest #puts_stderr "XrefLink $dest $label" set here [file split $here] set dest [file split $dest] #puts_stderr "XrefLink < $here" #puts_stderr "XrefLink > $dest" while {[string equal [lindex $dest 0] [lindex $here 0]]} { set dest [lrange $dest 1 end] set here [lrange $here 1 end] if {[llength $dest] == 0} {break} } set ul [llength $dest] set hl [llength $here] if {$ul == 0} { set dest [lindex [file split $save] end] } else { while {$hl > 1} { set dest [linsert $dest 0 ..] incr hl -1 } set dest [eval file join $dest] } #puts_stderr "XrefLink --> $dest" return $dest } # # ## ### ##### ######## ############# ##################### ## State global xref ; array set xref {} ## # # ## ### ##### ######## ############# ##################### return |
Changes to modules/doctools/mpformats/fmt.html.
︙ | ︙ | |||
8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # a manpage based upon HTML markup. # ################################################################ ################################################################ dt_source _common.tcl ; # Shared code dt_source _html.tcl ; # HTML basic formatting proc c_copyrightsymbol {} {return "[markup "&"]copy;"} proc bgcolor {} {return ""} proc border {} {return 0} proc Year {} {clock format [clock seconds] -format %Y} | > | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # a manpage based upon HTML markup. # ################################################################ ################################################################ dt_source _common.tcl ; # Shared code dt_source _html.tcl ; # HTML basic formatting dt_source _xref.tcl ; # xref management proc c_copyrightsymbol {} {return "[markup "&"]copy;"} proc bgcolor {} {return ""} proc border {} {return 0} proc Year {} {clock format [clock seconds] -format %Y} |
︙ | ︙ | |||
502 503 504 505 506 507 508 | if {!$para_is_open} {return ""} set para_is_open 0 return [tag/ p] } ################################################################ | | | 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 | if {!$para_is_open} {return ""} set para_is_open 0 return [tag/ p] } ################################################################ proc GetXref {} { Get xref } ;# xref access to engine parameters global __var array set __var { meta {} header {} footer {} xref {} |
︙ | ︙ | |||
626 627 628 629 630 631 632 | UL.doctools_requirements { margin-bottom: 1em; border-bottom: 1px solid black; } } ################################################################ | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 627 628 629 630 631 632 633 | UL.doctools_requirements { margin-bottom: 1em; border-bottom: 1px solid black; } } ################################################################ |
Changes to modules/doctools/mpformats/fmt.markdown.
1 2 3 4 5 6 7 8 9 | # -*- tcl -*- # Convert a doctools document into markdown formatted text # # Copyright (c) 2019 Andreas Kupries <[email protected]> # Note: While markdown is a text format its intended target is HTML, # making its formatting nearer to that with the ability to set anchors # and refer to them, linkage in general. | < < < < < < < > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # -*- tcl -*- # Convert a doctools document into markdown formatted text # # Copyright (c) 2019 Andreas Kupries <[email protected]> # Note: While markdown is a text format its intended target is HTML, # making its formatting nearer to that with the ability to set anchors # and refer to them, linkage in general. # # ## ### ##### ######## ############# ## Load shared code and modify it to our needs. dt_source _common.tcl dt_source _text.tcl dt_source fmt.text dt_source _markdown.tcl dt_source _xref.tcl rename PostProcess PostProcessT proc PostProcess {text} { string map [list [LB] " \n"] [PostProcessT $text] } proc LB {} { return "\1\n" } |
︙ | ︙ | |||
185 186 187 188 189 190 191 | if {[c_sectionKnown $id]} { return [ALink "#$id" $title] } else { return [Strong $title] } } | | > > > > | > > > > > > > > > > > > > | | 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | if {[c_sectionKnown $id]} { return [ALink "#$id" $title] } else { return [Strong $title] } } c_pass 1 fmt_usage {cmd args} { set text [join [linsert $args 0 $cmd] " "] c_hold synopsis "$text[LB.]" } c_pass 1 fmt_call {cmd args} { set text [join [linsert $args 0 $cmd] " "] set dest "#[c_cnext]" c_hold synopsis "[MakeLink $text $dest][LB.]" } c_pass 2 fmt_call {cmd args} { set text [join [linsert $args 0 $cmd] " "] return [fmt_lst_item [SetAnchor $text [c_cnext]]] } c_pass 1 fmt_require {pkg {version {}}} { set result "package require $pkg" if {$version != {}} {append result " $version"} c_hold require "$result " return } c_pass 2 fmt_tkoption_def {name dbname dbclass} { set text "" append text "Command-Line Switch:\t[fmt_option $name][LB]" append text "Database Name:\t[Strong $dbname][LB]" append text "Database Class:\t[Strong $dbclass]\n" fmt_lst_item $text } proc fmt_syscmd {text} { Strong [XrefMatch $text sa] } proc fmt_package {text} { Strong [XrefMatch $text sa kw] } proc fmt_term {text} { Em [XrefMatch $text kw sa] } proc fmt_arg {text} { Em $text } proc fmt_cmd {text} { Strong [XrefMatch $text sa] } proc fmt_method {text} { Strong $text } proc fmt_option {text} { Strong $text } proc fmt_uri {text {label {}}} { if {$label == {}} { set label $text } ALink $text $label } |
︙ | ︙ | |||
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | CloseCurrent } } return $img } c_pass 2 fmt_manpage_begin {title section version} { Off set module [dt_module] set shortdesc [c_get_module] set description [c_get_title] MDComment "$title - $shortdesc" MDComment [c_provenance] MDComment "[string trimleft $title :]($section) $version $module \"$shortdesc\"" | > > > > | 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | CloseCurrent } } return $img } c_pass 1 fmt_manpage_begin {title section version} {c_cinit ; c_clrSections ; return} c_pass 2 fmt_manpage_begin {title section version} { Off XrefInit c_cinit set module [dt_module] set shortdesc [c_get_module] set description [c_get_title] MDComment "$title - $shortdesc" MDComment [c_provenance] MDComment "[string trimleft $title :]($section) $version $module \"$shortdesc\"" |
︙ | ︙ | |||
310 311 312 313 314 315 316 | c_pass 2 fmt_manpage_end {} { set sa [c_xref_seealso] set kw [c_xref_keywords] set ca [c_xref_category] set ct [c_get_copyright] CloseParagraph | | | | 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | c_pass 2 fmt_manpage_end {} { set sa [c_xref_seealso] set kw [c_xref_keywords] set ca [c_xref_category] set ct [c_get_copyright] CloseParagraph if {[llength $sa]} { Special {SEE ALSO} see-also [join [XrefList [lsort $sa] sa] ", "] } if {[llength $kw]} { Special KEYWORDS keywords [join [XrefList [lsort $kw] kw] ", "] } if {$ca ne ""} { Special CATEGORY category $ca } if {$ct != {}} { Special COPYRIGHT copyright $ct [Verbatim] } return } proc c_get_copyright {} { return [join [c_get_copyright_r] [LB]] |
︙ | ︙ | |||
352 353 354 355 356 357 358 359 360 361 362 | # level in {1,2}, 1 = section, 2 = subsection Text [ALink "#$id" $name] CloseParagraph [lindex $toc $level] } return } ## # # ## ### ##### ######## return | > > > > > > > > > > > > > > > > > > > > | 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | # level in {1,2}, 1 = section, 2 = subsection Text [ALink "#$id" $name] CloseParagraph [lindex $toc $level] } return } # # ## ### ##### ######## ## Engine Parameters proc GetXref {} { Get xref } ;# xref access to engine parameters global __var array set __var { xref {} } proc Get {varname} {global __var ; return $__var($varname)} proc fmt_listvariables {} {global __var ; return [array names __var]} proc fmt_varset {varname text} { global __var if {![info exists __var($varname)]} { return -code error "Unknown engine variable \"$varname\"" } set __var($varname) $text return } ## # # ## ### ##### ######## return |
Changes to modules/doctools/tests/fmt/markdown/05.
︙ | ︙ | |||
15 16 17 18 19 20 21 | - [Description](#section1) - [Copyright](#copyright) # <a name='synopsis'></a>SYNOPSIS | | | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | - [Description](#section1) - [Copyright](#copyright) # <a name='synopsis'></a>SYNOPSIS [a-command](#1) # <a name='description'></a>DESCRIPTION OK - integer *argument-1* |
︙ | ︙ | |||
41 42 43 44 45 46 47 | elucidation - term definition | | | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | elucidation - term definition - <a name='1'></a>a-command semantic 1. A 1. B |
︙ | ︙ |
Changes to modules/doctools/tests/fmt/markdown/08.
︙ | ︙ | |||
27 28 29 30 31 32 33 | # <a name='synopsis'></a>SYNOPSIS package require AAA package require BBB VVV package require CCC ?VVV? | | | | | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | # <a name='synopsis'></a>SYNOPSIS package require AAA package require BBB VVV package require CCC ?VVV? [CMDNAME ...](#1) [CMDNAME ...](#2) [CMDNAME ...](#3) # <a name='description'></a>DESCRIPTION - __NAME__ DESCRIPTION ::__Command__:: |
︙ | ︙ | |||
77 78 79 80 81 82 83 | DESCRIPTION ::__Method__:: - TERM DESCRIPTION | | | | | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | DESCRIPTION ::__Method__:: - TERM DESCRIPTION - <a name='1'></a>CMDNAME ... DESCRIPTION ::__Namespace__:: * TYPE *NAME* DESCRIPTION ::*Argument*:: * TYPE *NAME* DESCRIPTION ::__Option__:: * TYPE *NAME* (MODE) DESCRIPTION ::?Optional?:: THE ARGUMENT IS USED IN THIS AND/OR THAT MANNER - <a name='2'></a>CMDNAME ... DESCRIPTION ::__Package__:: - <a name='3'></a>CMDNAME ... DESCRIPTION ::__SystemCommand__:: * __NAME__ DESCRIPTION ::*Term*:: |
︙ | ︙ |