api_called_proc_names (private)

 api_called_proc_names [ -body body ] -proc_name proc_name

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

Return list of procs called by the specified procname handle. Note that this function is based on "::apidoc::tcl_to_html", which is based on some heuristics and is not guaranteed to return always the correct results (it might contain false positives). Use this private function only, when heuristics are fine.

Switches:
-body (optional)
-proc_name (required)
name is fully qualified name without leading colons proc procs, XOTcl methods are a triple with the fully qualified class name, then proc|instproc and then the method name.
Author:
Gustaf Neumann

Partial Call Graph (max 5 caller/called nodes):
%3 test_callgraph__bad_library_calls callgraph__bad_library_calls (test acs-api-browser) api_called_proc_names api_called_proc_names test_callgraph__bad_library_calls->api_called_proc_names test_callgraph__bad_page_calls callgraph__bad_page_calls (test acs-api-browser) test_callgraph__bad_page_calls->api_called_proc_names apidoc::tcl_to_html apidoc::tcl_to_html (public) api_called_proc_names->apidoc::tcl_to_html apidoc::tclcode_to_html apidoc::tclcode_to_html (public) api_called_proc_names->apidoc::tclcode_to_html dom dom api_called_proc_names->dom api_add_calling_info_to_procdoc api_add_calling_info_to_procdoc (private) api_add_calling_info_to_procdoc->api_called_proc_names api_call_graph_snippet api_call_graph_snippet (private) api_call_graph_snippet->api_called_proc_names

Testcases:
callgraph__bad_library_calls, callgraph__bad_page_calls
Source code:
    if {[info exists body]} {
        #
        # Get the calling information directly from the body, when
        # e.g. the information is not in the procdoc nsv. This is
        # e.g. necessary, when getting calling info from *-init.tcl
        # files.
        #
        set body [apidoc::tclcode_to_html $body]
    } else {
        #
        # Get calling info from prettified proc body
        #
        try {
            ::apidoc::tcl_to_html $proc_name
        } on ok {result} {
            set body $result
            #ns_log notice "api_called_proc_names <$proc_name> got body <$body>"

        } on error {errorMsg} {
            ns_log warning "api_called_proc_names: cannot obtain body of '$proc_name'"  "via ::apidoc::tcl_to_html: $errorMsg"
            return ""
        }
    }

    dom parse -html <p>$body</p> doc
    $doc documentElement root
    set called {}

    foreach a [$root selectNodes //a] {
        set href [$a getAttribute href]
        #
        # When the href points to a proc, record this as calling info
        #
        if {[regexp {/api-doc/proc-view[?]proc=(.*)&} $href . called_proc]} {
            set called_proc [string trimleft [ns_urldecode $called_proc] :]
            lappend called $called_proc
        }
    }
    #ns_log notice "api_called_proc_names: <$proc_name> calls $called"
    return [lsort -unique $called]
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: