api_get_body (public)

 api_get_body proc_name

Defined in packages/acs-api-browser/tcl/acs-api-documentation-procs.tcl

This function returns the body of a Tcl proc or an XOTcl method.

Parameters:
proc_name - the name spec of the proc
Returns:
body of the specified proc

Partial Call Graph (max 5 caller/called nodes):
%3 test_acs_api_browser_api_get_body acs_api_browser_api_get_body (test acs-api-browser) api_get_body api_get_body test_acs_api_browser_api_get_body->api_get_body nsf::directdispatch nsf::directdispatch api_get_body->nsf::directdispatch nsf::is nsf::is api_get_body->nsf::is api_proc_documentation api_proc_documentation (public) api_proc_documentation->api_get_body apidoc::tcl_to_html apidoc::tcl_to_html (public) apidoc::tcl_to_html->api_get_body packages/acs-api-browser/www/proc-search.tcl packages/acs-api-browser/ www/proc-search.tcl packages/acs-api-browser/www/proc-search.tcl->api_get_body

Testcases:
acs_api_browser_api_get_body
Source code:
    #
    # In case the proc_name contains magic chars, these have to be
    # escaped for Tcl commands expecting a pattern (e.g. "info procs")
    #
    regsub -all -- {([?*])} $proc_name {\\\1} proc_name_pattern

    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]} {
                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]} {
                set body [::xo::api get_method_body "" ::$obj $prefix $method]
                set isNx [::nsf::directdispatch ::$obj  ::nsf::methods::object::info::hastype ::nx::Class]
            }
        }
        if {[info exists body]} {
            #
            # Beautify source code: delete the leading indent.
            # First check, if we have a nonempty 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 body [ns_trim -prefix $indent $body]
            }
            if {$isNx} {
                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]
    } elseif {[namespace which ::xo::api] ne ""
              && [regexp {(Class|Object) (.*)$} $proc_name . kind obj]} {
        return [::xo::api get_object_source "" $obj]
    } elseif {[info procs $proc_name_pattern] ne ""} {
        return [info body $proc_name]
    } elseif {[info procs ::nsf::procs::$proc_name_pattern] ne ""} {
        return [::nx::Object info method body ::nsf::procs::$proc_name]
    } else {
        return $proc_name
    }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: