Index: library/lib/doc-assets/attributemethod.html.asciidoc =================================================================== diff -u -N --- library/lib/doc-assets/attributemethod.html.asciidoc (revision 0) +++ library/lib/doc-assets/attributemethod.html.asciidoc (revision 7c5b655f1dded2eaf5792f0966de9e5410d26b3f) @@ -0,0 +1,51 @@ +
+
+
+ ${:name} +
+
+

obj ${:name} + ?value?

+ [$owning_attribute as_text] +
Parameters
+
+
value
+

If provided, list of values to be set for the attribute ${:name}

+
+ [:?objvar $owning_attribute @return { +
Return
+ [:!let ret [$owning_attribute !get @return]] + [$ret as_text] + }] + [:? {[$owning_attribute pinfo get -default 0 bundle incremental]} { +
+
+
+ ${:name} add +
+
+

obj ${:name} add value

+
Parameters
+
+
value
+

...

+
+
+
+
+
+
+ ${:name} delete +
+
+

obj ${:name} delete value

+
Parameters
+
+
value
+

...

+
+
+
+ }] +
+
Index: library/lib/doc-assets/class.html.asciidoc =================================================================== diff -u -N --- library/lib/doc-assets/class.html.asciidoc (revision 0) +++ library/lib/doc-assets/class.html.asciidoc (revision 7c5b655f1dded2eaf5792f0966de9e5410d26b3f) @@ -0,0 +1,106 @@ +
+[:as_text] +
+[:?var :@class-attribute { +[:!let class_attrs [:!get -sortedby name -with name @class-attribute]] +}] + +
+

Provided Parameters

+ [:? {[info exists class_attrs]} { +

+ + [:for attr [dict values $class_attrs] { + [$attr name] + }] + +

+ }] + [:!let iattrs [:inherited @class-attribute]] + [:? {$iattrs ne ""} { + [:for superclass [dict keys $iattrs] { + [:!let attrs [dict values [dict get $iattrs $superclass]]] +
Parameters inherited from [$superclass name]
+

+ + [:for a $attrs { + [$a name] + }] + +

+ }] + }] + + [:? {[info exists class_attrs]} { +
+ [:for attr [dict values $class_attrs] { +
+
+ [$attr name] +
+

[$attr as_text]

+ }] +
+ }] +
+ + +[:?var :@class-method { +[:!let class_methods [:!get -sortedby name -where {${:@modifier} eq "public"} @class-method]] +}] + +
+

Provided Methods

+ [:? {[info exists class_methods]} { +

+ + [:for m $class_methods { + [$m name] + }] + +

+ }] + [:!let imethods [:inherited @class-method]] + [:? {$imethods ne ""} { + [:for superclass [dict keys $imethods] { + [:!let ms [dict values [dict get $imethods $superclass]]] +
Methods inherited from [$superclass name]
+

+ + [:for m $ms { + [$m name] + }] + +

+ }] + }] + + [:? {[info exists class_methods]} { + [:for m $class_methods { + [:? {[info exists class_attrs] && [dict exists $class_attrs [$m name]]} { + [$m render -initscript [list set owning_attribute [dict get $class_attrs [$m name]]] attributemethod.html.asciidoc] + } - { + [$m render method.html.asciidoc] + }] + }] + }] +
+ + +[:?var :@object-method { +[:!let omethods [:!get -sortedby name @object-method]] +
+

Per-Object Methods

+

+ + [:for om $omethods { + [$om name] + }] + +

+ [:for om $omethods { + [$om render method.html.asciidoc] + }] +
+}] + Index: library/lib/doc-assets/class.html.tmpl =================================================================== diff -u -N -rbb292ab3dff4b1d3a65e0a532b691e8a6dcd688c -r7c5b655f1dded2eaf5792f0966de9e5410d26b3f --- library/lib/doc-assets/class.html.tmpl (.../class.html.tmpl) (revision bb292ab3dff4b1d3a65e0a532b691e8a6dcd688c) +++ library/lib/doc-assets/class.html.tmpl (.../class.html.tmpl) (revision 7c5b655f1dded2eaf5792f0966de9e5410d26b3f) @@ -83,7 +83,7 @@ }] [:!let iattrs [:inherited @class-attribute]] - [:? {$iattrs ne ""} { +[:? {$iattrs ne ""} {
[:for superclass [dict keys $iattrs] { [:!let attrs [dict values [dict get $iattrs $superclass]]] @@ -208,15 +208,7 @@
}] - - - -[:?var :@method { - Undocumented Methods: [:undocumented] -}] - - [:?var :@object-method { [:!let omethods [:!get -sortedby name @object-method]]
Index: library/lib/doc-assets/command.html.asciidoc =================================================================== diff -u -N --- library/lib/doc-assets/command.html.asciidoc (revision 0) +++ library/lib/doc-assets/command.html.asciidoc (revision 7c5b655f1dded2eaf5792f0966de9e5410d26b3f) @@ -0,0 +1,62 @@ +
+ [:as_text] +
+
Usage
+
${:name} + [:pinfo get -default "" bundle parametersyntax] + +
+[:?var :@command { +[:!let subs [:!get -sortedby name @command]] +[:for sub $subs { +
+
+
+ ${:name} [$sub name] +
+
+

[$sub as_text]

+
Usage
+
${:name} [$sub name] [:pinfo get -default "" bundle parametersyntax] +
+ [:?objvar $sub @parameter { +
Parameters
+
+ [:for param [$sub !get @parameter] { +
[$param print_name]
+

[$param as_text]

+ }] +
+ }] + [:?objvar $sub @return { +
Return
+ [:!let ret [$sub !get @return]] + [$ret as_text] + }] + +
+ +}] +} - { +[:?var :@parameter { +
Parameters
+
+ [:for param [:!get @parameter] { +
[$param print_name]
+

[$param as_text]

+ }] +
+}] +[:?var :@return { +
Return
+[:!let ret [:!get @return]] +[$ret as_text] +}] +}] + + + + + + + Index: library/lib/doc-assets/entity.html.tmpl =================================================================== diff -u -N --- library/lib/doc-assets/entity.html.tmpl (revision b067e586fadae95916358904fd8392d073c7c87c) +++ library/lib/doc-assets/entity.html.tmpl (revision 0) @@ -1,77 +0,0 @@ - - - - - API: ${:name} [:?var classname {$classname}] [:?var filename {$filename}] (A Next Library) - - - - - - - - - - -
-
-

[$project name]

-

${:name}  - [:? {[:info has type ::nx::doc::@package]} { - [:?var :@version {${:@version}} ] - } - { - [$project version] - }] -

- [$project name] - [:? {[:info has type ::nx::doc::@package]} { - > ${:name} - } ? {[:info has type ::nx::doc::@class]} { - > [:?var :partof {[${:partof} name] >}] ${:name} - }] -
-
- Search: -
-   -
-
-
-
- [:!let self_owned_parts [[:origin] owned_parts -class ::nx::doc::StructuredEntity]] - [:!let owned_parts [dict merge $project_entities $self_owned_parts]] -
-
-
- [:? {[:info has type ::nx::doc::@package]} { - [:include package.html.tmpl] - } ? {[:info has type ::nx::doc::@class]} { - [:include class.html.tmpl] - } ? {[:info has type ::nx::doc::@object]} { - [:include object.html.tmpl] - } ? {[:info has type ::nx::doc::@command]} { - [:include command.html.tmpl] - } ? {[:info has type ::nx::doc::@project]} { -
- This is the API documentation for the - [:name] project. -

Choose a package, object or command name from the list for more information.

-
- [:include glossary.html.tmpl] - }] -
-
-
- [:include leftbar.html.tmpl] -
-
-
-
- Copyright © [clock format [clock seconds] -format "%Y"] -
-
- - - Index: library/lib/doc-assets/link.html.asciidoc =================================================================== diff -u -N --- library/lib/doc-assets/link.html.asciidoc (revision 0) +++ library/lib/doc-assets/link.html.asciidoc (revision 7c5b655f1dded2eaf5792f0966de9e5410d26b3f) @@ -0,0 +1,4 @@ +[:? {![info exists cssclass]} { +[:!let cssclass nsfdoc-link] +}] +$source_anchor Index: library/lib/doc-assets/link.html.tmpl =================================================================== diff -u -N --- library/lib/doc-assets/link.html.tmpl (revision 0) +++ library/lib/doc-assets/link.html.tmpl (revision 7c5b655f1dded2eaf5792f0966de9e5410d26b3f) @@ -0,0 +1,4 @@ +[:? {![info exists cssclass]} { +[:!let cssclass nsfdoc-link] +}] +$source_anchor Index: library/lib/doc-assets/listing.html.asciidoc =================================================================== diff -u -N --- library/lib/doc-assets/listing.html.asciidoc (revision 0) +++ library/lib/doc-assets/listing.html.asciidoc (revision 7c5b655f1dded2eaf5792f0966de9e5410d26b3f) @@ -0,0 +1,3 @@ +[:? {$inline} {$script} - {
+
$script
+
}] Index: library/lib/doc-assets/listing.html.tmpl =================================================================== diff -u -N --- library/lib/doc-assets/listing.html.tmpl (revision 0) +++ library/lib/doc-assets/listing.html.tmpl (revision 7c5b655f1dded2eaf5792f0966de9e5410d26b3f) @@ -0,0 +1 @@ +[:? {$inline} {$script} - {$script}] Index: library/lib/doc-assets/method.html.asciidoc =================================================================== diff -u -N --- library/lib/doc-assets/method.html.asciidoc (revision 0) +++ library/lib/doc-assets/method.html.asciidoc (revision 7c5b655f1dded2eaf5792f0966de9e5410d26b3f) @@ -0,0 +1,30 @@ +
+
+
+ [:name] +
+
+

obj [:name] [:pinfo get -default "" bundle parametersyntax] +

+ [:?var :@method { + [:for sm [:get_sub_methods] { + [$sm render -initscript [list set supermethod [current]] submethod.html.asciidoc] + }] + } - { + [:?var :@parameter { +
Parameters
+
+ [:for param [:!get @parameter] { +
[$param print_name]
+
[$param as_text]
+ }] +
+ }] + [:?var :@return { +
Return
+ [:!let ret [:!get @return]] + [$ret as_text] + }] + }] +
+
Index: library/lib/doc-assets/multifile.html.tmpl =================================================================== diff -u -N --- library/lib/doc-assets/multifile.html.tmpl (revision 0) +++ library/lib/doc-assets/multifile.html.tmpl (revision 7c5b655f1dded2eaf5792f0966de9e5410d26b3f) @@ -0,0 +1,77 @@ + + + + + API: ${:name} [:?var classname {$classname}] [:?var filename {$filename}] (A Next Library) + + + + + + + + + + +
+
+

[$project name]

+

${:name}  + [:? {[:info has type ::nx::doc::@package]} { + [:?var :@version {${:@version}} ] + } - { + [$project version] + }] +

+ [$project name] + [:? {[:info has type ::nx::doc::@package]} { + > ${:name} + } ? {[:info has type ::nx::doc::@class]} { + > [:?var :partof {[${:partof} name] >}] ${:name} + }] +
+
+ Search: +
+   +
+
+
+
+ [:!let self_owned_parts [[:origin] owned_parts -class ::nx::doc::StructuredEntity]] + [:!let owned_parts [dict merge $project_entities $self_owned_parts]] +
+
+
+ [:? {[:info has type ::nx::doc::@package]} { + [:include package.html.tmpl] + } ? {[:info has type ::nx::doc::@class]} { + [:include class.html.tmpl] + } ? {[:info has type ::nx::doc::@object]} { + [:include object.html.tmpl] + } ? {[:info has type ::nx::doc::@command]} { + [:include command.html.tmpl] + } ? {[:info has type ::nx::doc::@project]} { +
+ This is the API documentation for the + [:name] project. +

Choose a package, object or command name from the list for more information.

+
+ [:include glossary.html.tmpl] + }] +
+
+
+ [:include leftbar.html.tmpl] +
+
+
+
+ Copyright © [clock format [clock seconds] -format "%Y"] +
+
+ + + Index: library/lib/doc-assets/object.html.asciidoc =================================================================== diff -u -N --- library/lib/doc-assets/object.html.asciidoc (revision 0) +++ library/lib/doc-assets/object.html.asciidoc (revision 7c5b655f1dded2eaf5792f0966de9e5410d26b3f) @@ -0,0 +1,20 @@ +
+ [:as_text] +
+ +[:?var :@object-method { +[:!let omethods [:!get -sortedby name @object-method]] +
+

Per-Object Methods

+

+ + [:for om $omethods { + [$om name] + }] + +

+ [:for om $omethods { + [$om render method.html.asciidoc] + }] +
+}] Index: library/lib/doc-assets/package.html.asciidoc =================================================================== diff -u -N --- library/lib/doc-assets/package.html.asciidoc (revision 0) +++ library/lib/doc-assets/package.html.asciidoc (revision 7c5b655f1dded2eaf5792f0966de9e5410d26b3f) @@ -0,0 +1,45 @@ + +

+ [:as_text] +

+ +[:?var :@require { +
Required packages
+

${:@require}

+}] + +[:?var :@class { +
Contained classes
+
+ +
+}] + +[:?var :@object { +
Contained objects
+
+ +
+}] + +[:?var :@command { +
Contained commands
+
+ +
+}] + + Index: library/lib/doc-assets/singlefile.html.asciidoc =================================================================== diff -u -N --- library/lib/doc-assets/singlefile.html.asciidoc (revision 0) +++ library/lib/doc-assets/singlefile.html.asciidoc (revision 7c5b655f1dded2eaf5792f0966de9e5410d26b3f) @@ -0,0 +1,102 @@ + + + + + + API: ${:name} [:?var classname {$classname}] [:?var filename {$filename}] (A Next Library) + + + + + + +[:!let tmpls [dict create ::nx::doc::@class class.html.asciidoc ::nx::doc::@package package.html.asciidoc ::nx::doc::@object object.html.asciidoc ::nx::doc::@command command.html.asciidoc]] +
+ [:for feature [dict keys $project_entities] { + [:for inst [dict get $project_entities $feature] { +
+

[$feature pretty_name] [$inst name]

+
+ [:? {[dict exists $tmpls [$inst info class]]} { + [$inst render [dict get $tmpls [$inst info class]]] + }] +
+
+ }] + }] + [:?var :@glossary { +
+

Glossary

+
+ [:!let entries [sorted [:@glossary] name]] + [:for entry $entries { + [:!let ddesc [$entry as_text]] + [:?objvar $entry @acronym { + [:!let dtext [$entry @acronym]] + [:? {$ddesc ne ""} { + [:!let ddesc "[$entry @pretty_name] — $ddesc"] + } - { + [:!let ddesc "[$entry @pretty_name]"] + }] + } - { + [:!let dtext [$entry @pretty_name]] + }] +
+ $dtext +
+
+

$ddesc

+ [:?objvar $entry refs { + [:? {[$entry eval [concat dict exists \${:refs} [current]]]} { +

+ [:!let refs [sort_by_value [$entry eval [concat dict get \${:refs} [current]]]]] + [:for src [dict keys $refs] { + + [$src make_link [current]] +  ([dict get $refs $src]) + + }] +

+ }] + }] +
+ }] +
+
+ }] +
+ + + Index: library/lib/doc-assets/submethod.html.asciidoc =================================================================== diff -u -N --- library/lib/doc-assets/submethod.html.asciidoc (revision 0) +++ library/lib/doc-assets/submethod.html.asciidoc (revision 7c5b655f1dded2eaf5792f0966de9e5410d26b3f) @@ -0,0 +1,25 @@ +[:!let name [:get_combined name]] +
+
+
+ $name +
+
+

obj $name [:pinfo get -default "" bundle parametersyntax] +

+ [:?var :@parameter { +
Parameters
+
+ [:for param [:!get @parameter] { +
[$param print_name]
+

[$param as_text]

+ }] +
+ }] + [:?var :@return { +
Return
+ [:!let ret [:!get @return]] + [$ret as_text] + }] +
+
Index: library/lib/doc-assets/submethod.html.tmpl =================================================================== diff -u -N -re4a5c3979effc10d1e807063956d51c72994db6e -r7c5b655f1dded2eaf5792f0966de9e5410d26b3f --- library/lib/doc-assets/submethod.html.tmpl (.../submethod.html.tmpl) (revision e4a5c3979effc10d1e807063956d51c72994db6e) +++ library/lib/doc-assets/submethod.html.tmpl (.../submethod.html.tmpl) (revision 7c5b655f1dded2eaf5792f0966de9e5410d26b3f) @@ -1,39 +1,39 @@ [:!let name [:get_combined name]] -
-

$name[:statusmark] -

-
- [:? {[info exists :@return] && [${:@return} spec] ne ""} {<[${:@return} spec]>} ] - obj - $name - [:pinfo get -default "" bundle parametersyntax] - -
- [:as_text] - [:? {[info exists :@parameter]} { -
-
Parameters:
- [:for param ${:@parameter} { -
- [$param name] - [:? {[$param eval {info exists :spec}] && [$param spec] ne ""} {<[$param spec]>}] - - [$param statusmark] - [$param as_text] +
+

$name[:statusmark] +

+
+ [:? {[info exists :@return] && [${:@return} spec] ne ""} {<[${:@return} spec]>} ] + obj + $name + [:pinfo get -default "" bundle parametersyntax] + +
+ [:as_text] + [:? {[info exists :@parameter]} { +
+
Parameters:
+ [:for param ${:@parameter} { +
+ [$param name] + [:? {[$param eval {info exists :spec}] && [$param spec] ne ""} {<[$param spec]>}] + + [$param statusmark] + [$param as_text] [$param pinfo get -default "" validation] -
- }] -
- }] - [:? {[info exists :@return]} { -
-
Returns: - -
-
[${:@return} as_text]
-
- }] -
-
-
-
+
+ }] +
+ }] + [:? {[info exists :@return]} { +
+
Returns: + +
+
[${:@return} as_text]
+
+ }] +
+
+
+
Index: library/lib/doc-tools.tcl =================================================================== diff -u -N -re5e9c27b9617efadb97eaa357bee46edda368302 -r7c5b655f1dded2eaf5792f0966de9e5410d26b3f --- library/lib/doc-tools.tcl (.../doc-tools.tcl) (revision e5e9c27b9617efadb97eaa357bee46edda368302) +++ library/lib/doc-tools.tcl (.../doc-tools.tcl) (revision 7c5b655f1dded2eaf5792f0966de9e5410d26b3f) @@ -130,7 +130,7 @@ } - Class create MixinLayer -superclass Class { + Class create MixinLayer { :attribute {prefix ""} :public method init {} { set :active_mixins [dict create] @@ -335,7 +335,8 @@ return [string trimleft [string map [list [:root_namespace] ""] $qualified_name] ":"] } :public method get_tail_name {qualified_name} { - return [string trimleft [string map [list ${:tag} ""] [:get_unqualified_name $qualified_name]] ":"] + #return [string trimleft [string map [list ${:tag} ""] [:get_unqualified_name $qualified_name]] ":"] + return [join [lrange [concat {*}[split [:get_unqualified_name $qualified_name] "::"]] 1 end] "::"] } } @@ -889,6 +890,8 @@ } :attribute @package -class ::nx::doc::PartAttribute { + :pretty_name "Package" + :pretty_plural "Packages" set :part_class ::nx::doc::@package } @@ -1393,21 +1396,29 @@ namespace eval ::nx::doc { - Class create Renderer { - :public method run {} { - :render=[namespace tail [:info class]] - } - } + Class create TemplateData { + + :class-object attribute current_format + :class-object attribute current_theme + :public forward current_format [current] %method + :public forward current_theme [current] %method - Class create TemplateData { + # + # TODO: For now, this acts as the counterweight to "origin", + # when @use aliasing is used, processed_entity can be used to + # refer to the actual entity at the upper end of the aliasing + # chain. Verify, whether this is an acceptable approach ... + # + :class-object attribute rendered_entity:object,type=::nx::doc::Entity + :public forward rendered_entity [current] %method - :public method write_data {content path} { - set fh [open $path w] - puts $fh $content - catch {close $fh} + :method initialise {with_template_path} { + :rendered_entity [current] + foreach {f t} [lrange [split $with_template_path .] end-1 end] break; + :current_format $f + :current_theme $t } - :public method read_tmpl {path} { if {[file pathtype $path] ne "absolute"} { set assetdir [find_asset_path] @@ -1447,14 +1458,14 @@ # figured out (as for the origin mechanism) we so keep track # of the actual rendered entity ... review later ... # - $entity rendered_entity $entity + $entity initialise $template $entity render_start set content [$entity eval [subst -nocommands { $initscript $tmplscript }]] $entity render_end - return $content + return [string trim $content \n] } @@ -1549,8 +1560,10 @@ uplevel 1 [list subst [:read_tmpl $template]] } - :method code args { - error "Subclass responsibility: You must provide a method definition of '[current method]' in a proper subclass" + :method listing {{-inline true} script} { + set iscript [join [list [list set inline $inline] [list set script $script]] \n] + :render -initscript $iscript [current method].[:current_format].[:current_theme] + } :method link args { @@ -1621,8 +1634,10 @@ # distinguish errors on unintended and intended evaluations. # ... if {[catch {set preprocessed [subst $preprocessed]} msg]} { + puts stderr SELF=[current] puts stderr MSG=$msg puts stderr IN->$preprocessed + puts stderr errorInfo->$::errorInfo } return $preprocessed } @@ -1634,61 +1649,120 @@ # Doc templates. # - MixinLayer create NxDocRenderer -superclass Renderer -prefix ::nx::doc { - :public method run {{-tmpl entity.html.tmpl} {-outdir /tmp}} { + Class create Renderer -superclass MixinLayer { + + :method init args { + set :prefix "::nx::doc" + next + } - # - # Note: For now, this method is called upon a @project - # instance. This may change during continued refactoring. - # - - # 1) apply the mixin layer - [current class] apply - - # 2) proceed by rendering the project's parts (package, class, - # object, and command entities) - set ext [lindex [split [file tail $tmpl] .] end-1] - set top_level_entities [:navigatable_parts] - set init [subst { - set project \[:current_project\] - set project_entities \[list $top_level_entities\] - }] - set project_path [file join $outdir [string trimleft ${:name} :]] + :method write {content path} { + set fh [open $path w] + puts $fh $content + catch {close $fh} + } + :method remove {{-nocomplain:switch} path} { + if {![file exists $path] && !$nocomplain} { + error "Path does not exists: '$path'." + } + file delete -force $path + } + + :method "pick multifile" { + project + tmpl + {-outdir [::nsf::tmpdir]} + } { + set ext [namespace tail [current]] + set project_path [file join $outdir [string trimleft [$project name] :]] + + :remove -nocomplain $project_path + if {![catch {file mkdir $project_path} msg]} { - set assets [lsearch -all -inline -glob -not [glob -directory [find_asset_path] *] *.tmpl] + set assets [glob -directory [::nx::doc::find_asset_path] *] + set assets [lsearch -all -inline -glob -not $assets *.$ext] set target $project_path/assets file mkdir $target file copy -force -- {*}$assets $target - set values [join [dict values $top_level_entities]] - + set values [concat {*}[dict values [$project navigatable_parts]]] # # Make sure that the @project entity is processed last. # - lappend values [current object] + lappend values $project # Note: We trigger the validation of entities according to # their pdata once for the entire entity hierarchy, starting # from the root, i.e. the project entity. - :validate foreach e $values { # # TODO: For now, in templates we (silently) assume that we act # upon structured entities only ... # if {![$e info has type ::nx::doc::StructuredEntity]} continue; - $e current_project [current object] - set content [$e render -initscript $init $tmpl] - :write_data $content [file join $project_path "[$e filename].$ext"] + set content [:render $project $e $tmpl] + :write $content [file join $project_path "[$e filename].$ext"] puts stderr "$e written to [file join $project_path [$e filename].$ext]" } } - - # 3) TODO: revoke the application of the mixin layer (for the sake of - # some sort of bounded quantification) - [current class] revoke } + :method "pick singlefile" { + project + tmpl + {-outdir "[::nsf::tmpdir]"} + } { + set ext [namespace tail [current]] + set fn [file join $outdir "[$project name].$ext"] + :remove -nocomplain $fn + set content [:render $project $project $tmpl] + :write $content $fn + puts stderr "$project written to $fn" + } + + :public method run { + -project + {-layout multifile} + {-theme tmpl} + args + } { + # 1. trigger validation + $project validate + + # 2. verify whether there is ... + # i) a layout handler and + # ii) a template matching both the layout/theme specified + set ext [namespace tail [current]] + set tmpl $layout.$ext.$theme + set path_to_tmpl [file join [::nx::doc::find_asset_path] $tmpl] + if {![file exists $path_to_tmpl] || \ + [:info lookup method "pick $layout"] eq "" + } { + error "Beware, $ext $layout output for theme '$theme' not supported." + } + + # 3) proceed + :apply + :pick $layout $project $tmpl {*}$args + :revoke + } + + :method render {project entity tmpl} { + error "Not implemented. Instance responsibility!" + } + } + + Renderer create html { + :method render {project entity tmpl} { + set top_level_entities [$project navigatable_parts] + set init [subst { + set project $project + set project_entities \[list $top_level_entities\] + }] + $entity current_project $project + $entity render -initscript $init $tmpl + } + # # The actual refinements delivered by the mixin layer # @@ -1707,15 +1781,6 @@ # :class-object attribute current_project:object,type=::nx::doc::@project # :public forward current_project [current] %method - # - # TODO: For now, this acts as the counterweight to "origin", - # when @use aliasing is used, processed_entity can be used to - # refer to the actual entity at the upper end of the aliasing - # chain. Verify, whether this is an acceptable approach ... - # - :class-object attribute rendered_entity:object,type=::nx::doc::Entity - :public forward rendered_entity [current] %method - # :public forward print_name %current name :public method statusmark {} { set cls "" @@ -1779,9 +1844,11 @@ } :method listing {{-inline true} script} { - #return [expr {$inline?"$script":"
$script
"}] - set listing [expr {$inline?"$script":[string trimright [nx::pp render [string trimright $script " \r\n"]] "\n"]}] - return $listing + set listing $script + if {!$inline} { + set listing [string trimright [nx::pp render [string trimright $script " \r\n"]] "\n"] + } + next [list -inline $inline $listing] } :method link=tclcmd {cmd} { @@ -1830,12 +1897,10 @@ } :public method render_link {tag source path} { - #puts stderr PATH=$path set id [current] set pathnames [dict values $path] set entities [dict keys $path] set top_entity [lindex $entities 0] - # puts stderr RESOLPATH([$id info class])=$path set pof "" if {$top_entity ne $id} { set pof "[$top_entity name]#" @@ -1844,8 +1909,12 @@ } #return "$pof[join $pathnames .]" # GN TODO: Maybe a nicer "title" attribute via method title? - return "[join $pathnames { }]" + #return "[join $pathnames { }]" + set iscript [join [list [list set title $pof[join $pathnames .]] \ + [list set source_anchor [join $pathnames { }]] \ + [list set top_entity $top_entity]] \n] + :render -initscript $iscript link.[:current_format].[:current_theme] } :public method as_text {} { @@ -1882,6 +1951,15 @@ return [[:info class] tag]_[string trimleft [string map {:: __} ${:name}] "_"] } } + + :public method as_tag_id {} { + set tagclass [:info class] + set tail [$tagclass get_tail_name [current]] + set tname [string trimleft [string map {:: _} $tail] "_"] + return [$tagclass tag]__$tname + } + + }; # NxDocTemplating::Entity MixinLayer::Mixin create [current]::@project -superclass [current]::Entity { @@ -1967,15 +2045,13 @@ if {!$acronym(short) && ($acronym(long) || ![info exists :refs] || \ ![dict exists ${:refs} [:current_project] $source])} { set print_name "$print_name (${:@acronym})" - set res "$print_name" } else { set title $print_name set print_name ${:@acronym} set anchor "$print_name" - set res "$anchor" + # TODO: Re-provide the environment + #set res "$anchor" } - } else { - set res "$print_name" } # record for reverse references @@ -1985,8 +2061,16 @@ dict update :refs [:current_project] prj { dict incr prj $source } + + set iscript [join [list [list set title $title] \ + [list set source_anchor $print_name] \ + [list set top_entity [current]] \ + [list set cssclass nsfdoc-gloss]] \n] + set res [:render \ + -initscript $iscript \ + link.[:current_format].[:current_theme]] return $res - } + } }; # NxDocRenderer::@glossary MixinLayer::Mixin create [current]::@class -superclass [current]::Entity { @@ -3121,31 +3205,31 @@ # mixin layer interface # - :class-object method apply {} { + :method apply {} { unset -nocomplain :processed_entities next } - :class-object method revoke {} { + :method revoke {} { next if {[info exists :processed_entities]} { return [dict keys ${:processed_entities}] } } - :public class-object method at_processed {entity} { + :public method at_processed {entity} { dict set :processed_entities $entity _ } # # processor interface # - :class-object method log {msg} { + :method log {msg} { puts stderr "[current]->[uplevel 1 [list ::nsf::current method]]: $msg" } - :public class-object method process { + :public method process { -sandboxed:switch -validate:switch {-type project} @@ -3275,7 +3359,7 @@ return $project } - :protected class-object method process=@package {project pkgs} { + :protected method process=@package {project pkgs} { set box [$project sandbox] $box permissive_pkgs [string tolower $pkgs] set 1pass "" @@ -3324,7 +3408,7 @@ # set ft [::xotcl::metadataAnalyzer::FileToken allinstances] if {[llength $ft] > 1} { - error "Too many xodoc file tokes processed. Expecting just one!" + error "Too many xodoc file tokens processed. Expecting just one!" } set partof $project @@ -3340,7 +3424,7 @@ } } - :protected class-object method process=package {project pkgs} { + :protected method process=package {project pkgs} { set box [$project sandbox] $box permissive_pkgs $pkgs set 1pass "" @@ -3384,9 +3468,9 @@ return $provided_entities } - :protected class-object method process=source {project filepath} {;} + :protected method process=source {project filepath} {;} - :protected class-object method process=eval {project scripts} { + :protected method process=eval {project scripts} { set box [$project sandbox] # # 1a) 1pass ... TODO: should tracing be enabled in this scenario? ... @@ -3438,7 +3522,7 @@ } } - :public class-object method readin { + :public method readin { -docstring:switch -tag -name @@ -3496,7 +3580,7 @@ } } - :public class-object method analyze_line {line} { + :public method analyze_line {line} { set regex {^[\s#]*#+(.*)$} if {[regexp -- $regex $line --> comment]} { return [list 1 [string trimright $comment]] @@ -3505,7 +3589,7 @@ } } - :public class-object method comment_blocks {script} { + :public method comment_blocks {script} { set lines [split $script \n] set comment_blocks [list] set was_comment 0 @@ -3541,9 +3625,9 @@ # distinguished from @object (dispatch along the inheritance # hierarchy?) - :public class-object method process=@command {project entity} {;} + :public method process=@command {project entity} {;} - :public class-object method process=@class {project entity} { + :public method process=@class {project entity} { set name [$entity name] set box [$project sandbox] # attributes @@ -3594,7 +3678,7 @@ # we pass a parameter value, revisit this decision once we decide # on a location for this behaviour. # - :public class-object method process=@object {project entity {scope ""}} { + :public method process=@object {project entity {scope ""}} { set name [$entity name] set box [$project sandbox] # methods @@ -3641,13 +3725,11 @@ } :public method doc { - {-renderer ::nx::doc::HtmlRenderer} - -project:object,type=::nx::doc::@project + {-format html} + project:object,type=::nx::doc::@project args } { - $project mixin add $renderer - $project run {*}$args - $project mixin delete $renderer + $format run -project $project {*}$args } } Index: tests/doc.test =================================================================== diff -u -N -r84921e055921d2ee9adf2853048cf05b3bf62643 -r7c5b655f1dded2eaf5792f0966de9e5410d26b3f --- tests/doc.test (.../doc.test) (revision 84921e055921d2ee9adf2853048cf05b3bf62643) +++ tests/doc.test (.../doc.test) (revision 7c5b655f1dded2eaf5792f0966de9e5410d26b3f) @@ -1063,13 +1063,6 @@ } puts stderr ================================================= -foreach path [list [file join [::nsf::tmpdir] NextScriptingFramework] \ - [file join [::nsf::tmpdir] NextScriptingLanguage] \ - [file join [::nsf::tmpdir] XOTcl2]] { - if {[file exists $path]} { - file delete -force $path - } -} # TODO: Figure out where to place nsf.nxd for convenient location ... @@ -1118,8 +1111,10 @@ -include $::nsf::includes $project] ::nx::doc::make doc \ - -renderer ::nx::doc::NxDocRenderer \ - -project $project \ + -format html \ + $project \ + -theme tmpl \ + -layout multifile \ -outdir [::nsf::tmpdir] puts stderr >>>>>>>NextScriptingLanguage<<<<<<<< @@ -1131,32 +1126,46 @@ ::nx::slotObj } -set _ [time { - set project [::nx::doc::@project new \ - -name NextScriptingLanguage \ - -url http://www.next-scripting.org/ \ - -version 1.0.0a \ - -@namespace "::nx" \ - -sources { - package nx - } -depends $project] +set project [::nx::doc::@project new \ + -name NextScriptingLanguage \ + -url http://www.next-scripting.org/ \ + -version 1.0.0a \ + -@namespace "::nx" \ + -sources { + package nx + } -depends $project] + +dict set timings process [time { + # ISSUE: If calling '-namespace "::nx"' instead of '-@namespace # "::nx"', we get an irritating failure. VERIFY! processor process \ -validate \ -sandboxed \ -exclude $::nx::excludes \ $project +} 1] - ::nx::doc::make doc \ - -renderer ::nx::doc::NxDocRenderer \ - -project $project \ +dict set timings make.html.yuidoc [time { + ::nx::doc::make doc $project \ -outdir [::nsf::tmpdir] } 1] -puts stderr ">>>>> gross timing for $project $_" +dict set timings make.html.asciidoc [time { +::nx::doc::make doc \ + -format html \ + $project \ + -theme asciidoc \ + -layout singlefile \ + -outdir [::nsf::tmpdir] +} 1] +dict for {probe t} $timings { + puts stderr "\t$probe -> $t" +} + +exit set project [::nx::doc::@project new \ -name XOTcl2 \ -url http://www.xotcl.org/ \ @@ -1171,7 +1180,8 @@ $project ::nx::doc::make doc \ - -renderer ::nx::doc::NxDocRenderer \ + -format html \ + -theme tmpl \ -project $project \ -outdir [::nsf::tmpdir]