Skip to content

Commit 37fedfe

Browse files
fix examples for cache
1 parent d456a4f commit 37fedfe

8 files changed

+56
-20
lines changed

R/detect-alignment.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
#' @keywords internal
2828
#' @examples
2929
#' library("magrittr")
30+
#' withr::with_options(
31+
#' list(styler.cache_name = NULL), # temporarily deactivate cache
32+
#' {
3033
#' transformers <- tidyverse_style()
3134
#' pd_nested <- styler:::compute_parse_data_nested(c(
3235
#' "call(",
@@ -37,6 +40,7 @@
3740
#' styler:::post_visit(transformers$initialize)
3841
#' nest <- pd_nested$child[[1]]
3942
#' styler:::token_is_on_aligned_line(nest)
43+
#' })
4044
token_is_on_aligned_line <- function(pd_flat) {
4145
line_idx <- 1 + cumsum(pd_flat$lag_newlines)
4246
pd_flat$.lag_spaces <- lag(pd_flat$spaces)

R/initialize.R

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@
55
#' @param pd_flat A parse table.
66
#' @importFrom utils tail
77
#' @examples
8-
#' string_to_format <- "call( 3)"
9-
#' pd <- styler:::compute_parse_data_nested(string_to_format)
10-
#' styler:::pre_visit(pd, c(default_style_guide_attributes))
8+
#' withr::with_options(
9+
#' list(styler.cache_name = NULL), # temporarily deactivate cache
10+
#' {
11+
#' string_to_format <- "call( 3)"
12+
#' pd <- styler:::compute_parse_data_nested(string_to_format)
13+
#' styler:::pre_visit(pd, c(default_style_guide_attributes))
14+
#' }
15+
#' )
1116
#' @export
1217
#' @keywords internal
1318
default_style_guide_attributes <- function(pd_flat) {

R/nested-to-tree.R

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,15 @@ create_tree_from_pd_with_default_style_attributes <- function(pd, structure_only
3030
#' @return An object of class "Node" and "R6".
3131
#' @examples
3232
#' if (rlang::is_installed("data.tree")) {
33-
#' cache_deactivate() # keep things simple
34-
#' code <- "a <- function(x) { if(x > 1) { 1+1 } else {x} }"
35-
#' nested_pd <- styler:::compute_parse_data_nested(code)
36-
#' initialized <- styler:::pre_visit(nested_pd, c(default_style_guide_attributes))
37-
#' styler:::create_node_from_nested_root(initialized, structure_only = FALSE)
33+
#' withr::with_options(
34+
#' list(styler.cache_name = NULL), # temporarily deactivate cache
35+
#' {
36+
#' code <- "a <- function(x) { if(x > 1) { 1+1 } else {x} }"
37+
#' nested_pd <- styler:::compute_parse_data_nested(code)
38+
#' initialized <- styler:::pre_visit(nested_pd, c(default_style_guide_attributes))
39+
#' styler:::create_node_from_nested_root(initialized, structure_only = FALSE)
40+
#' }
41+
#' )
3842
#' }
3943
#' @keywords internal
4044
create_node_from_nested_root <- function(pd_nested, structure_only) {

R/utils-navigate-nest.R

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,13 @@ previous_non_comment <- function(pd, pos) {
4848
#' nested structure.
4949
#' @keywords internal
5050
#' @examples
51-
#' pd <- styler:::compute_parse_data_nested("if (TRUE) f()")
52-
#' styler:::next_terminal(pd)
51+
#' withr::with_options(
52+
#' list(styler.cache_name = NULL), # temporarily deactivate cache
53+
#' {
54+
#' pd <- styler:::compute_parse_data_nested("if (TRUE) f()")
55+
#' styler:::next_terminal(pd)
56+
#' }
57+
#' )
5358
next_terminal <- function(pd,
5459
stack = FALSE,
5560
vars = c("pos_id", "token", "text"),

man/create_node_from_nested_root.Rd

Lines changed: 9 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/default_style_guide_attributes.Rd

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/next_terminal.Rd

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/token_is_on_aligned_line.Rd

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)