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 -N -r1.27.8.22 -r1.27.8.23 --- openacs-4/packages/acs-api-browser/tcl/acs-api-documentation-procs.tcl 10 Sep 2014 20:19:26 -0000 1.27.8.22 +++ openacs-4/packages/acs-api-browser/tcl/acs-api-documentation-procs.tcl 11 Sep 2014 08:01:04 -0000 1.27.8.23 @@ -105,7 +105,7 @@ regsub -all {\#.*$} $line "" line set line [string trim $line] if { $line ne "" } { - set has_contract_p [regexp {^ad_page_contract\s} $line] + set has_contract_p [regexp {(^ad_page_contract\s)|( initialize )} $line match] break } } @@ -116,20 +116,25 @@ } doc_set_page_documentation_mode 1 + #ns_log notice "Sourcing $::acs::rootdir/$path in documentation mode" set errno [catch { source "$::acs::rootdir/$path" } error] doc_set_page_documentation_mode 0 - if { $errno == 1 } { - if { [regexp {^ad_page_contract documentation} $::errorInfo] } { + + # + # In documentation mode, we expect ad_page_contract (and counterparts) + # to break out of sourcing with an error to avoid side-effects of sourcing + # + if { $errno == 1} { + if {[regexp {^ad_page_contract documentation} $::errorInfo] } { array set doc_elements $error } - } else { - return -code $errno -errorcode $::errorCode -errorinfo $::errorInfo $error + if { [info exists doc_elements] } { + return [array get doc_elements] + } + return [list] } - if { [info exists doc_elements] } { - return [array get doc_elements] - } - return [list] + return -code $errno -errorcode $::errorCode -errorinfo $::errorInfo $error } ad_proc -public api_script_documentation { @@ -928,9 +933,7 @@ @return boolean value } { set result 0 - if {[string match "::*" $proc_name]} { ;# only check for absolute names - catch {set result [::xotcl::api inscope $scope ::xotcl::Object isobject $proc_name]} - } + catch {set result [::xotcl::api inscope $scope ::xotcl::Object isobject $proc_name]} return $result }