Index: library/lib/nxdoc-core.tcl =================================================================== diff -u -r5bb824230bdec762db1607482bd9866be01184af -redea1a9c44f4c685e45e59e7f8864ae11d84ff42 --- library/lib/nxdoc-core.tcl (.../nxdoc-core.tcl) (revision 5bb824230bdec762db1607482bd9866be01184af) +++ library/lib/nxdoc-core.tcl (.../nxdoc-core.tcl) (revision edea1a9c44f4c685e45e59e7f8864ae11d84ff42) @@ -2333,7 +2333,6 @@ {*}[expr {[::nsf::var::exists $obj __initcmd] && [::nsf::var::set $obj __initcmd] ne ""?[list ->docstring [::nsf::var::set $obj __initcmd]]:[list]}] return $obj } - ::nsf::mixin $rootmclass ${::nx::doc::rootns}::__Tracer # ::nsf::relation $rootmclass class-mixin ${::nx::doc::rootns}::__Tracer if {[info commands "::nx::Object"] ne ""} { @@ -2392,6 +2391,9 @@ ::nsf::mixin $rootclass ${::nx::doc::rootns}::__ObjTracer #::nsf::relation $rootclass class-mixin ${::nx::doc::rootns}::__ObjTracer } + + ::nsf::mixin $rootmclass ${::nx::doc::rootns}::__Tracer + } ::interp invokehidden "" proc ::nx::doc::handleinfo {handle} { set definition [::nsf::dispatch ${::nx::doc::rootns}::__Tracer ::nsf::methods::object::info::method definition $handle] @@ -2567,7 +2569,7 @@ } } - # 2) provide for tracing Tcl procs declared at "sourcing time" -> [proc] + # 2a) provide for tracing Tcl procs declared at "sourcing time" -> [proc] #::interp hide "" proc ::interp invokehidden "" proc ::proc {name arguments body} { set ns [uplevel [list namespace current]] @@ -2587,6 +2589,26 @@ } } + + rename ::nsf::proc ::nsf::_%&proc + ::interp invokehidden "" proc ::nsf::proc {name arguments body} { + set ns [uplevel [list namespace current]] + uplevel [list ::nsf::_%&proc $name $arguments $body] + set fqn $name + if {[string first "::" $name] != 0} { + set fqn [string trimright $ns :]::$name + } + if {$arguments eq "" && $body eq ""} { + ::nx::doc::__at_deregister_command $fqn + } else { + ::nx::doc::__at_register_command $fqn \ + ->cmdtype @command \ + ->source [file normalize [info script]] \ + ->nsexported [::nx::doc::is_exported $fqn] \ + ->docstring $body + } + } + # 3) provide for tracing commands namespace-imported at "sourcing time" #::interp hide "" namespace ::interp invokehidden "" proc ::namespace {subcmd args} { @@ -3105,8 +3127,8 @@ @method }]] - puts stderr generated_commands=$generated_commands - puts stderr present_entities=$present_entities + #puts stderr generated_commands=$generated_commands + #puts stderr present_entities=$present_entities set map [dict create] foreach pe $present_entities { if {[$pe pinfo exists bundle handle]} { @@ -3291,7 +3313,7 @@ $box registered_commands [$box get_registered_commands $nsFilters] } - puts stderr REGISTERED_COMMANDS=[dict keys [$box registered_commands]] + # puts stderr REGISTERED_COMMANDS=[dict keys [$box registered_commands]] foreach {attr part_class} [$project part_attributes] { @@ -4045,7 +4067,7 @@ # :method parse@space {line} {;} } - ::nsf::proc mkIndex {{-documentAll:switch 0} -indexfiles:0..* {-outdir "[pwd]"} args} { + ::nsf::proc mkIndex {{-documentAll:switch 0} {-indexfiles:0..* ""} {-outdir "[pwd]"} args} { if {![llength $args]} { set args *.tcl @@ -4062,21 +4084,40 @@ if {![llength $scripts]} return; set sbox [Sandbox new -interp [interp create]] - $sbox do [list package req nx] + # 1pass + append scriptBlock "source " [join $scripts "; source "] + $sbox do [list package req nsf] + $sbox do $scriptBlock + # 2pass $sbox do [list ::nx::doc::__init] + $sbox do $scriptBlock + set cmds [dict keys [$sbox get_registered_commands -types {@command @object @class}]] + + append index "# NXDoc index file, version [package require nx::doc]\n" + append index "# This file was generated by the \"::nx::doc::mkIndex\" command\n" + append index "# and is optionally sourced by nxdoc to filter the command population\n" + append index "# to be documented. Typically each line is a command that\n" + append index "# sets an element in the ::nxdoc::include array, where the\n" + append index "# element name is the name of a command and the value indicates whether\n" + append index "# the command is to be documented (1) or not (0).\n" + append index \n - set cmds [list] - foreach script $scripts { - $sbox do [list source $script] - puts stderr >>>[$sbox get_registered_commands -types {@command @object @class}] - lappend cmds {*}[dict keys [$sbox get_registered_commands -types {@command @object @class}]] + if {[llength $indexfiles]} { + append index "# Source external (e.g., auto-generated) index files\n" } - + + foreach idx $indexfiles { + append index {source [file join [file dirname [info script]] } $idx {]} "\n" + } + foreach cmd $cmds { - puts stderr "set ::nxdoc::include($cmd) $documentAll" + append index "set ::nxdoc::include($cmd) $documentAll\n" } - } - + + set fid [open [file join [file normalize $outdir] nxdocIndex] w] + puts -nonewline $fid $index + close $fid + } } # puts stderr "Doc Tools loaded: [info command ::nx::doc::*]" \ No newline at end of file