Build the call tree of every function defined in a directory of R files
call_tree_dir.Rdcall_tree_dir() parses every .R file in path without evaluating any
of it, extracts each top-level function definition
(name <- function(...) ...), and builds the call graph among those
locally-defined functions. The result is the tree of calls reachable
from root, in the same shape call_stack() returns, so it prints the
same way.
Unlike call_stack(), which resolves an already-loaded function through
R's own namespace lookup, call_tree_dir() never loads or runs the
scanned files. That makes it usable on a package's R/ directory, or a
Shiny app's source, without installing or sourcing it first.
Arguments
- path
Character scalar; directory containing
.Rfiles. Default"R".- root
Character scalar; name of the function to root the tree at. Must be one of the top-level functions found in
path.- modules_only
Logical. When
TRUE, prune the tree torootplus functions that callshiny::NS()orshiny::moduleServer()(Shiny modules); everything else is spliced out, promoting its children so modules reached through a non-module wrapper function stay visible. DefaultFALSE, which keeps every locally-defined function reachable fromroot.
Value
An object of class call_stack (see call_stack()).
See also
call_tree_app() for the equivalent on a running Shiny app.