api_call_graph_snippet (private)

 api_call_graph_snippet -proc_name proc_name [ -dpi dpi ] \
    [ -format format ] [ -maxnodes maxnodes ] \
    [ -textpointsize textpointsize ]

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

Return a source code for dot showing a local call graph snippet, showing direct callers and directly called functions

Switches:
-proc_name
(required)
-dpi
(defaults to "72") (optional)
-format
(defaults to "svg") (optional)
-maxnodes
(defaults to "5") (optional)
-textpointsize
(defaults to "12.0") (optional)
Author:
Gustaf Neumann

Partial Call Graph (max 5 caller/called nodes):
%3 api_proc_documentation api_proc_documentation (public) api_call_graph_snippet api_call_graph_snippet api_proc_documentation->api_call_graph_snippet api_called_proc_names api_called_proc_names (private) api_call_graph_snippet->api_called_proc_names api_proc_doc_url api_proc_doc_url (private) api_call_graph_snippet->api_proc_doc_url api_proc_pretty_name api_proc_pretty_name (public) api_call_graph_snippet->api_proc_pretty_name api_test_case_url api_test_case_url (private) api_call_graph_snippet->api_test_case_url export_vars export_vars (public) api_call_graph_snippet->export_vars

Testcases:
No testcase defined.
Source code:

    set dot_code ""

    #
    # Include calls from test cases
    #
    set doc [nsv_get api_proc_doc $proc_name]
    if {[dict exists $doc testcase]} {
        set nodes ""
        set edges ""
        foreach testcase_pair [lrange [lsort [dict get $doc testcase]] 0 $maxnodes-1] {
            lassign $testcase_pair testcase_id package_key
            set testcase_node test_$testcase_id
            set url [api_test_case_url $testcase_pair]
            set props ""
            append props  [subst {URL="$url", margin=".2,0", shape=none, tooltip="Testcase $testcase_id of package $package_key", }]  [subst {label=<<FONT POINT-SIZE="$textpointsize">$testcase_id<BR/><I>(test $package_key)</I></FONT>>}]
            append nodes [subst -nocommands {"$testcase_node" [$props];\n}]
            append edges [subst {"$testcase_node" -> "$proc_name";}] \n
        }
        append dot_code  "subgraph \{\nrank=\"source\";"  $nodes  "\}\n"  $edges
    }

    #
    # Include calls from calledby information. Might come from a file
    # (e.g. a *-init.tcl file) or from a proc.
    #
    set callers {}
    if {[dict exists $doc calledby]} {
        set edges ""
        set nodes ""

        #
        # Filter from the list the recursive calls, since these mess
        # up the graph layout.
        #
        set caller_procs {}
        foreach c [dict get $doc calledby] {
            if { $c ne $proc_name } {
                lappend caller_procs $c
            }
        }

        foreach caller [lrange [lsort $caller_procs] 0 $maxnodes-1] {
            #
            # When the "caller" starts with "packages/", we assume,
            # this is a file.
            #
            if {[regexp {^(packages/[^/]+/)(.*)} $caller . line1 line2]} {
                set url [export_vars -base /api-doc/content-page-view {{path $caller} {source_p 1}}]
                set props ""
                append props  [subst {URL="$url", margin=".2,0" shape=rectangle, tooltip="Script calling $proc_name", }]  [subst {label=<<FONT POINT-SIZE="$textpointsize">${line1}<BR/>${line2}</FONT>>}]
            } else {
                lappend callers $caller
                set url [api_proc_doc_url -proc_name $caller]
                set hints [api_proc_pretty_name -hints_only $caller]
                if {$hints ne ""} {
                    set hints "<BR/><I>$hints</I>"
                }
                set props ""
                append props  [subst {URL="$url", margin=".2,0" tooltip="Function calling $proc_name", }]  [subst {label=<<FONT POINT-SIZE="$textpointsize">${caller}$hints</FONT>>}]
            }
            append nodes [subst -nocommands {"$caller" [$props];\n}]
            append edges [subst {"$caller" -> "$proc_name";}] \n
        }
        append dot_code  "subgraph \{\nrank=\"same\";"  $nodes  "\}\n"  $edges
    }

    #
    # Include information, what other procs this proc calls.  Filter
    # from this list false positives of the call graph
    # analysis. Exclude es well recursive calls, since these mess up
    # the graph layout.
    #
    set called_procs {}
    foreach c [api_called_proc_names -proc_name $proc_name] {
        if {[namespace which $c] eq "::$c"
            && $c ni $callers
            && $c ne $proc_name
        } {
            lappend called_procs $c
        }
    }

    set edges ""
    set nodes ""
    foreach called [lrange $called_procs 0 $maxnodes-1] {
        set url [api_proc_doc_url -proc_name $called]
        set hints [api_proc_pretty_name -hints_only $called]
        if {$hints ne ""} {
            set hints "<BR/><I>$hints</I>"
        }
        set props ""
        append props  [subst {URL="$url", margin=".2,0", tooltip="Function called by $proc_name", }]  [subst {label=<<FONT POINT-SIZE="$textpointsize">${called}$hints</FONT>>}]
        append nodes [subst -nocommands {"$called" [$props];\n}]
        append edges [subst {"$proc_name" -> "$called";}] \n
    }
    if {$nodes ne ""} {
        append dot_code  "subgraph \{\nrank=\"same\";"  $nodes  "\}\n"  $edges
    }
    #ns_log notice \n$dot_code
    append result "digraph \{api = $dpi;" $dot_code "\}"
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: