Index: apps/utils/nxdoc =================================================================== diff -u -rfa7635cbfe2309b8e6282e2c7925fa2617b061aa -r5bb824230bdec762db1607482bd9866be01184af --- apps/utils/nxdoc (.../nxdoc) (revision fa7635cbfe2309b8e6282e2c7925fa2617b061aa) +++ apps/utils/nxdoc (.../nxdoc) (revision 5bb824230bdec762db1607482bd9866be01184af) @@ -27,9 +27,10 @@ # # input # - :property sourcepath - :property {includes ""} + :property includes :property {excludes ""} + :property indexfiles:alias + :protected property sources:1..* { set :config false } @@ -38,12 +39,61 @@ # auxiliary # + :private method barf {msg} { + return -code error "NXDOC: $msg" + } + :protected method ... args { :sources [concat {*}[split $args :]] } + :protected method indexfiles {paths} { + # + # TODO: Should we provide for an auto-lookup of nxdocIndex files, + # similar to tclIndex or pkgIndex.tcl? + # + + # + # Some sanity checks first ... + # + set sources [list] + foreach p $paths { + set p [file normalize $p] + if {[file exists $p] && [file readable $p]} { + lappend sources [list source $p] + } else { + :barf "Cannot find or read the index file '$p'" + } + } + + if {$sources eq ""} return; + + set i [interp create] + $i eval { + proc ::unknown args { puts stderr "UNKNOWN: $args"} + namespace eval ::nxdoc::internal { + proc getIndexedCmds {{choice 0}} { + if {[array exists ::nxdoc::include]} { + array set out [list 0 "" 1 ""] + foreach {v cmd} [lreverse [array get ::nxdoc::include]] { + lappend out($v) $cmd + } + return [lindex [array get out $choice] 1] + } + } + } + } + if {[catch {$i eval [join $sources ";"]} err]} { + :barf "Sourcing index files failed with error message '$err'" + } + + lappend :includes {*}[$i eval [list ::nxdoc::internal::getIndexedCmds 1]] + interp delete $i + } + :protected class method objectparameter {} { - foreach slot [:info slot objects -type ::nx::VariableSlot] { + set slots [:info slot objects] + foreach slot $slots { lappend defs([$slot position]) [$slot getParameterSpec] } set parameterdefinitions [list] @@ -63,7 +113,8 @@ processor process \ -sandboxed \ {*}[expr {${:validation}?"-validate":""}] \ - -include ${:includes} $prj + {*}[expr {[info exists :includes]?"-include [list ${:includes}]":""}] \ + $prj make doc \ -format ${:format} \ Index: library/lib/nxdoc-core.tcl =================================================================== diff -u -rfa7635cbfe2309b8e6282e2c7925fa2617b061aa -r5bb824230bdec762db1607482bd9866be01184af --- library/lib/nxdoc-core.tcl (.../nxdoc-core.tcl) (revision fa7635cbfe2309b8e6282e2c7925fa2617b061aa) +++ library/lib/nxdoc-core.tcl (.../nxdoc-core.tcl) (revision 5bb824230bdec762db1607482bd9866be01184af) @@ -2634,7 +2634,7 @@ } :protected property {interp ""}; # the default empty string points to the current interp - :property registered_commands + :public property registered_commands :public method getCompanions {identifiers} { set scripts [list] @@ -2677,7 +2677,7 @@ } { if {[info exists nspatterns]} { set opts [join $nspatterns |] - # set nspatterns "^($opts)\[^\:\]*\$" + # set nspatterns "^($opts)\[^\:\]*\$" set nspatterns "^($opts)\$" } dict filter ${:registered_commands} script {cmd props} { @@ -3059,9 +3059,19 @@ dict lappend sources $type $name } + + set nsFilters [list] + if {[info exists include] && $include ne ""} { + set nsFilters [list $include] + } + if {[info exists exclude] && $exclude ne ""} { + set nsFilters [list -not $exclude] + } + + set provided_entities [list] dict for {type instances} $sources { - lappend provided_entities {*}[:[current method]=$type $project $instances] + lappend provided_entities {*}[:[current method]=$type $project $instances {*}$nsFilters] } if {$validate} { @@ -3079,13 +3089,6 @@ #puts stderr "NSF: [join [dict keys [$box get_registered_commands -exported -types @command]] \n]" # ISSUE: -exported turns out to be a weak filter criterion, it # excludes slot objects from being processed! - set nsfilters [list] - if {[info exists include] && $include ne ""} { - set nsfilters [list $include] - } - if {[info exists exclude] && $exclude ne ""} { - set nsfilters [list -not $exclude] - } # # TODO: Add support for "generated" packages and their @@ -3097,10 +3100,13 @@ @object @class @command - } {*}$nsfilters] \ + }] \ [$box get_registered_commands -types { @method - } {*}$nsfilters]] + }]] + + 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]} { @@ -3242,7 +3248,7 @@ } } - :protected method process=package {project pkgs} { + :protected method process=package {project pkgs nsFilters:optional} { set box [$project sandbox] $box permissive_pkgs $pkgs set 1pass "" @@ -3277,6 +3283,16 @@ } $box do "::nx::doc::__init; $2pass" } + + # + # filter registered commands for includes/excludes + # + if {[info exists nsFilters]} { + $box registered_commands [$box get_registered_commands $nsFilters] + } + + puts stderr REGISTERED_COMMANDS=[dict keys [$box registered_commands]] + foreach {attr part_class} [$project part_attributes] { $part_class class mixin add ::nx::doc::ContainerEntity::Containable @@ -3293,6 +3309,7 @@ set scripts [$box get_companions] set provided_entities [list] + foreach script $scripts { lappend provided_entities {*}[:readin $script] } @@ -4027,6 +4044,39 @@ } # :method parse@space {line} {;} } + + ::nsf::proc mkIndex {{-documentAll:switch 0} -indexfiles:0..* {-outdir "[pwd]"} args} { + + if {![llength $args]} { + set args *.tcl + } + + set scripts [list] + foreach file [glob -- {*}$args] { + set file [file normalize $file] + if {[file readable $file]} { + lappend scripts $file + } + } + + if {![llength $scripts]} return; + + set sbox [Sandbox new -interp [interp create]] + $sbox do [list package req nx] + $sbox do [list ::nx::doc::__init] + + 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}]] + } + + foreach cmd $cmds { + puts stderr "set ::nxdoc::include($cmd) $documentAll" + } + } + } # puts stderr "Doc Tools loaded: [info command ::nx::doc::*]" \ No newline at end of file