Index: openacs-4/packages/acs-api-browser/tcl/acs-api-documentation-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-api-browser/tcl/acs-api-documentation-procs.tcl,v diff -u -r1.72.2.33 -r1.72.2.34 --- openacs-4/packages/acs-api-browser/tcl/acs-api-documentation-procs.tcl 28 Oct 2021 07:56:49 -0000 1.72.2.33 +++ openacs-4/packages/acs-api-browser/tcl/acs-api-documentation-procs.tcl 28 Oct 2021 10:10:28 -0000 1.72.2.34 @@ -1167,16 +1167,48 @@ if {[namespace which ::xo::api] ne "" && [regexp {^(.*) (inst)?proc (.*)$} $proc_name match obj prefix method]} { set method [lindex $proc_name end] + if {[regexp {^(.*) (.*)$} $obj match scope obj]} { if {[::xo::api scope_eval $scope ::nsf::is object $obj]} { - return [::xo::api get_method_source $scope ::$obj $prefix $method] + set body [::xo::api get_method_body $scope ::$obj $prefix $method] + set isNx [::xo::api scope_eval $scope \ + ::nsf::directdispatch ::$obj \ + ::nsf::methods::object::info::hastype ::nx::Class] } } else { if {[::nsf::is object $obj]} { - return [::xo::api get_method_source "" ::$obj $prefix $method] + set body [::xo::api get_method_body "" ::$obj $prefix $method] + set isNx [::nsf::directdispatch ::$obj \ + ::nsf::methods::object::info::hastype ::nx::Class] } } - return "" + if {[info exists body]} { + if {$isNx} { + # + # Beautify source code: delete the leading indent. + # First check, if we have an non-empty indent... + # + set lines [split $body \n] + set firstNonEmptyLine "" + foreach line $lines { + if {[regexp {^(\s+)\S} $line . indent]} { + break + } + } + # + # if we have some indent, remove it from the lines. + # + if {[info exists indent]} { + set lines [lmap line $lines { + set x [regexp "^${indent}(.*)$" $line . line] + set line + }] + set body [join $lines \n] + } + set doc [::xo::api get_doc_block $body body] + } + return $body + } } elseif {[namespace which ::xo::api] ne "" && [regexp {^([^ ]+) (Class|Object) (.*)$} $proc_name . thread kind obj]} { return [::xo::api get_object_source $thread $obj] @@ -1484,7 +1516,6 @@ set proc_namespace "" regexp {^(::)?(.*)::[^:]+$} $proc_name match colons proc_namespace - return [tclcode_to_html -scope $scope -proc_namespace $proc_namespace [api_get_body $proc_name]] } Index: openacs-4/packages/xotcl-core/tcl/03-doc-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/03-doc-procs.tcl,v diff -u -r1.22.2.9 -r1.22.2.10 --- openacs-4/packages/xotcl-core/tcl/03-doc-procs.tcl 27 Oct 2021 19:34:25 -0000 1.22.2.9 +++ openacs-4/packages/xotcl-core/tcl/03-doc-procs.tcl 28 Oct 2021 10:10:28 -0000 1.22.2.10 @@ -321,7 +321,7 @@ } if {$restVar ne ""} { upvar $restVar rest - set rest [join [lrange $lines $i end] \n] + set rest [join [lrange $lines $i-1 end] \n] } #ns_log notice "=================== get_doc_block RETURNS <$docBlock>" return $docBlock @@ -526,6 +526,9 @@ } :public object method get_object_source {scope obj} { + # + # Return the full object definition + # if {![nsf::is object $obj]} { ns_log warning "[self] get_object_source: argument passed as obj is not an object: $obj" return "" @@ -540,10 +543,24 @@ } :public object method get_method_source {scope obj prefix method} { + # + # Return the full method definition + # :scope_eval $scope ::Serializer methodSerialize $obj $method $prefix } + :public object method get_method_body {scope obj prefix method} { + # + # Return the method body ("prefix" is ignored) + # + :scope_eval $scope ::nsf::dispatch $obj ::nsf::methods::class::info::method body $method + } + :public object method update_nx_docs {{objects ""}} { + # + # Update for the provided (or all) nx::Object instances the + # internal documentation structures. + # if {[llength $objects] == 0} { set objects [nx::Object info instances -closure] } @@ -576,7 +593,7 @@ } } -::nx::Class public method init {} { +::nx::Class method init {} { set r [next] # # When loading the blueprint, ::xo::api might not be available yet