Skip to main content

CallTree

One node of a call tree: a function name and the calls it makes.

Usage

Source

CallTree(
    name,
    calls=list(),
    key=None,
)

Every tree builder in callgrove returns a CallTree. Printing it (or showing it in a REPL) draws the tree in the style of R’s lobstr::ast(). A node with children is prefixed with █─; a leaf is plain text. Children hang off ├─ and └─ branches, one indent per level.

Parameters

name: str

The function name, as written at the call site.

calls: list[CallTree] = list()
Child nodes, in the order the calls appear in the source.

Examples

>>> CallTree("main", [CallTree("load", [CallTree("open")]), CallTree("run")])

█─main ├─█─load │ └─open └─run