@@ -47,6 +47,23 @@ ContextBuilder <- R6Class(
4747 }
4848 )
4949)
50+ # ' Register a graph context for the duration of the current frame
51+ # '
52+ # ' This function sets the provided graph to be the context for tidygraph
53+ # ' algorithms, such as e.g. [node_is_center()], for the duration of the current
54+ # ' environment. It automatically removes the graph once the environment exits.
55+ # '
56+ # ' @param graph A `tbl_graph` object
57+ # '
58+ # ' @param free Should the active state of the graph be ignored?
59+ # '
60+ # ' @param env The environment where the context should be active
61+ # '
62+ # ' @keywords internal
63+ # ' @name graph-context
64+ # ' @rdname graph-context
65+ NULL
66+ # ' @rdname graph-context
5067# ' @export
5168.graph_context <- ContextBuilder $ new()
5269expect_nodes <- function () {
@@ -102,20 +119,8 @@ NULL
102119 .graph_context $ edges(focused )
103120}
104121
105- # ' Register a graph context for the duration of the current frame
106- # '
107- # ' This function sets the provided graph to be the context for tidygraph
108- # ' algorithms, such as e.g. [node_is_center()], for the duration of the current
109- # ' environment. It automatically removes the graph once the environment exits.
110- # '
111- # ' @param graph A `tbl_graph` object
112- # '
113- # ' @param free Should the active state of the graph be ignored?
114- # '
115- # ' @param env The environment where the context should be active
116- # '
122+ # ' @rdname graph-context
117123# ' @export
118- # ' @keywords internal
119124.register_graph_context <- function (graph , free = FALSE , env = parent.frame()) {
120125 check_tbl_graph(graph )
121126 if (identical(env , .GlobalEnv )) {
128133 do.call(on.exit , alist(expr = .graph_context $ clear(), add = TRUE ), envir = env )
129134 invisible (NULL )
130135}
136+
137+ # ' @rdname graph-context
138+ # ' @export
131139.free_graph_context <- function (env = parent.frame()) {
132140 if (identical(env , .GlobalEnv )) {
133141 cli :: cli_abort(' A context cannot be freed in the global environment' )
0 commit comments