Skip to contents

Search the code graph for definitions by name

Usage

graph_search(graph, pattern, kind = NULL)

Arguments

graph

A insider_graph from build_graph(), or a target (source directory / installed package name) to build one from.

pattern

Regular expression matched against node names.

kind

Optional filter: one or more of "function", "object", "s4_class", "s4_generic", "s4_method", "r5_class", "r5_method", "r6_class", "r6_method".

Value

A data frame of matching nodes (name, kind, file, lines, exported).

Examples

dir <- tempfile()
dir.create(dir)
writeLines("f <- function(x) g(x)\ng <- function(x) x + 1", file.path(dir, "code.R"))
g <- build_graph(dir, cache = FALSE)
graph_search(g, "^f")
#>   name     kind   file line_start line_end exported
#> 1    f function code.R          1        1       NA