Skip to content

Commit 3bd53b0

Browse files
use @Keywords internal for unexported functions
1 parent 26413c6 commit 3bd53b0

File tree

135 files changed

+252
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+252
-1
lines changed

R/addins.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ NULL
1818

1919
#' @describeIn styler_addins Styles the active file with [tidyverse_style()] and
2020
#' `strict = TRUE`.
21+
#' @keywords internal
2122
style_active_file <- function() {
2223
transformer <- make_transformer(tidyverse_style())
2324
context <- get_rstudio_context()
@@ -46,6 +47,7 @@ style_active_file <- function() {
4647
#' @param context The context from `styler:::get_rstudio_context()`.
4748
#' @param transformer A transformer function most conveniently constructed with
4849
#' [make_transformer()].
50+
#' @keywords internal
4951
try_transform_as_r_file <- function(context, transformer) {
5052
tryCatch(
5153
transformer(context$contents),
@@ -62,6 +64,7 @@ try_transform_as_r_file <- function(context, transformer) {
6264

6365
#' @describeIn styler_addins Styles the highlighted selection in a `.R` or
6466
#' `.Rmd` file.
67+
#' @keywords internal
6568
style_selection <- function() {
6669
context <- get_rstudio_context()
6770
text <- context$selection[[1]]$text

R/communicate.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#' @param changed Boolean with indicating for each file whether or not it has
66
#' been changed.
77
#' @inheritParams can_verify_roundtrip
8+
#' @keywords internal
89
communicate_warning <- function(changed, transformers) {
910
if (any(changed, na.rm = TRUE) && !can_verify_roundtrip(transformers)) {
1011
cat("Please review the changes carefully!")
@@ -16,6 +17,7 @@ communicate_warning <- function(changed, transformers) {
1617
#' @param changed Boolean with indicating for each file whether or not it has
1718
#' been changed.
1819
#' @param ruler_width Integer used to determine the width of the ruler.
20+
#' @keywords internal
1921
communicate_summary <- function(changed, ruler_width) {
2022
cli::cat_rule(width = max(40, ruler_width))
2123
cat("Status\tCount\tLegend \n")

R/expr-is.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
#'
33
#' @param pd A parse table.
44
#' @name pd_is
5+
#' @keywords internal
56
NULL
67

78
#' @describeIn pd_is Checks whether `pd` contains an expression wrapped in
89
#' curly brackets.
10+
#' @keywords internal
911
is_curly_expr <- function(pd) {
1012
if (is.null(pd)) return(FALSE)
1113
pd$token[1] == "'{'"
@@ -17,13 +19,15 @@ is_subset_expr <- function(pd) {
1719
}
1820

1921
#' @describeIn pd_is Checks whether `pd` is a function call.
22+
#' @keywords internal
2023
is_function_call <- function(pd) {
2124
if (is.null(pd)) return(FALSE)
2225
if (is.na(pd$token_before[2])) return(FALSE)
2326
pd$token_before[2] == "SYMBOL_FUNCTION_CALL"
2427
}
2528

2629
#' @describeIn pd_is Checks whether `pd` is a function declaration.
30+
#' @keywords internal
2731
is_function_dec <- function(pd) {
2832
if (is.null(pd)) return(FALSE)
2933
pd$token[1] == "FUNCTION"
@@ -42,6 +46,7 @@ is_comment <- function(pd) {
4246
#' @param pd A parse table.
4347
#' @examples
4448
#' style_text("#!/usr/bin/env Rscript")
49+
#' @keywords internal
4550
is_shebang <- function(pd) {
4651
is_first_comment <- is_comment(pd) & (pd$pos_id == 1L)
4752
is_first_comment[is_first_comment] <- grepl(
@@ -61,6 +66,7 @@ is_shebang <- function(pd) {
6166
#' "call(3, 2, c(3:2))"
6267
#' ))
6368
#' @param pd A parse table.
69+
#' @keywords internal
6470
is_code_chunk_header <- function(pd) {
6571
is_comment <- is_comment(pd)
6672
is_comment[is_comment] <- grepl(
@@ -80,6 +86,7 @@ contains_else_expr <- function(pd) {
8086
#' else-if will be visited separately with the visitor. This applies to all
8187
#' conditional statements with more than one alternative.
8288
#' @param pd A parse table
89+
#' @keywords internal
8390
contains_else_expr_that_needs_braces <- function(pd) {
8491
else_idx <- which(pd$token == "ELSE")
8592
if (length(else_idx) > 0) {

R/indent.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
#' @param indent_by How many spaces should be added after the token of interest.
66
#' @param token The token the indention should be based on.
77
#' @name update_indention
8+
#' @keywords internal
89
NULL
910

1011
#' @describeIn update_indention Inserts indention based on round, square and
1112
#' curly brackets.
13+
#' @keywords internal
1214
indent_braces <- function(pd, indent_by) {
1315
indent_indices <- compute_indent_indices(
1416
pd,
@@ -21,6 +23,7 @@ indent_braces <- function(pd, indent_by) {
2123

2224
#' @describeIn update_indention Indents *all* tokens after `token` - including
2325
#' the last token.
26+
#' @keywords internal
2427
indent_op <- function(pd,
2528
indent_by,
2629
token = c(
@@ -41,6 +44,7 @@ indent_op <- function(pd,
4144
#' Necessary for consistent indention of the function declaration header.
4245
#' @param pd A parse table.
4346
#' @seealso set_unindention_child update_indention_ref_fun_dec
47+
#' @keywords internal
4448
unindent_fun_dec <- function(pd) {
4549
if (is_function_dec(pd)) {
4650
idx_closing_brace <- which(pd$token %in% "')'")
@@ -55,6 +59,7 @@ unindent_fun_dec <- function(pd) {
5559
#' table are necessarily indented, as `EQ_SUB` and `EQ_FORMALS` can occur
5660
#' multiple times in a parse table.
5761
#' occurs is not indented (see[compute_indent_indices()])
62+
#' @keywords internal
5863
indent_eq_sub <- function(pd,
5964
indent_by,
6065
token = c("EQ_SUB", "EQ_FORMALS")) {
@@ -69,6 +74,7 @@ indent_eq_sub <- function(pd,
6974

7075
#' @describeIn update_indention Same as indent_op, but only indents one token
7176
#' after `token`, not all remaining.
77+
#' @keywords internal
7278
indent_assign <- function(pd, indent_by, token = NULL) {
7379
indent_indices <- compute_indent_indices(pd, token)
7480
pd$indent[indent_indices] <- pd$indent[indent_indices] + indent_by
@@ -77,6 +83,7 @@ indent_assign <- function(pd, indent_by, token = NULL) {
7783

7884
#' @describeIn update_indention Is used to indent for / while / if / if-else
7985
#' statements that do not have curly parenthesis.
86+
#' @keywords internal
8087
indent_without_paren <- function(pd, indent_by = 2) {
8188
pd %>%
8289
indent_without_paren_for_while_fun(indent_by) %>%
@@ -85,6 +92,7 @@ indent_without_paren <- function(pd, indent_by = 2) {
8592

8693
#' @describeIn update_indention Is used to indent for and statements and function
8794
#' definitions without parenthesis.
95+
#' @keywords internal
8896
indent_without_paren_for_while_fun <- function(pd, indent_by) {
8997
nrow <- nrow(pd)
9098
if (!(pd$token[1] %in% c("FOR", "WHILE", "FUNCTION"))) return(pd)
@@ -95,6 +103,7 @@ indent_without_paren_for_while_fun <- function(pd, indent_by) {
95103

96104
#' @describeIn update_indention Is used to indent if and if-else statements.
97105
#' @importFrom rlang seq2
106+
#' @keywords internal
98107
indent_without_paren_if_else <- function(pd, indent_by) {
99108
expr_after_if <- next_non_comment(pd, which(pd$token == "')'")[1])
100109
has_if_without_curly <-
@@ -138,6 +147,7 @@ indent_without_paren_if_else <- function(pd, indent_by) {
138147
#' everything between '(' and the penultimate token would result in the wrong
139148
#' formatting.
140149
#' @importFrom rlang seq2
150+
#' @keywords internal
141151
compute_indent_indices <- function(pd,
142152
token_opening,
143153
token_closing = NULL) {
@@ -166,6 +176,7 @@ compute_indent_indices <- function(pd,
166176
#' @param potential_triggers_pos A vector with indices of the potential trigger
167177
#' tokens in `pd`.
168178
#' @inheritParams needs_indention_one
179+
#' @keywords internal
169180
needs_indention <- function(pd,
170181
potential_triggers_pos,
171182
other_trigger_tokens = NULL) {
@@ -191,6 +202,7 @@ needs_indention <- function(pd,
191202
#' if on the same line as the token corresponding to `potential_trigger`.
192203
#' @return `TRUE` if indention is needed, `FALSE` otherwise.
193204
#' @importFrom rlang seq2
205+
#' @keywords internal
194206
needs_indention_one <- function(pd,
195207
potential_trigger_pos,
196208
other_trigger_tokens) {
@@ -222,6 +234,7 @@ needs_indention_one <- function(pd,
222234
#' of a token is a multi-line token.
223235
#' @param pd A parse table.
224236
#' @importFrom purrr map_lgl
237+
#' @keywords internal
225238
set_multi_line <- function(pd) {
226239
pd$multi_line <- map_lgl(pd$child, pd_is_multi_line)
227240
pd
@@ -234,6 +247,7 @@ set_multi_line <- function(pd) {
234247
#' * it contains a line break.
235248
#' * it has at least one child that is a multi-line expression itself.
236249
#' @param pd A parse table.
250+
#' @keywords internal
237251
pd_is_multi_line <- function(pd) {
238252
any(pd$multi_line, pd$lag_newlines > 0)
239253
}
@@ -250,6 +264,7 @@ pd_is_multi_line <- function(pd) {
250264
#' @param pd A parse table.
251265
#' @return A parse table with synchronized `lag_newlines` and `newlines` columns.
252266
#' @seealso choose_indention
267+
#' @keywords internal
253268
update_newlines <- function(pd) {
254269
npd <- nrow(pd) - 1
255270
pd$newlines[seq_len(npd)] <- pd$lag_newlines[seq_len(npd) + 1]

R/initialize.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#' pd <- styler:::compute_parse_data_nested(string_to_format)
1010
#' styler:::pre_visit(pd, c(default_style_guide_attributes))
1111
#' @export
12+
#' @keywords internal
1213
default_style_guide_attributes <- function(pd_flat) {
1314
init_pd <-
1415
initialize_newlines(pd_flat) %>%
@@ -25,9 +26,11 @@ default_style_guide_attributes <- function(pd_flat) {
2526
#'
2627
#' @name initialize_attributes
2728
#' @inheritParams default_style_guide_attributes
29+
#' @keywords internal
2830
NULL
2931

3032
#' @describeIn initialize_attributes Initializes `newlines` and `lag_newlines`.
33+
#' @keywords internal
3134
initialize_newlines <- function(pd_flat) {
3235
pd_flat$line3 <- lead(pd_flat$line1, default = tail(pd_flat$line2, 1))
3336
pd_flat$newlines <- pd_flat$line3 - pd_flat$line2
@@ -37,6 +40,7 @@ initialize_newlines <- function(pd_flat) {
3740
}
3841

3942
#' @describeIn initialize_attributes Initializes `spaces`.
43+
#' @keywords internal
4044
initialize_spaces <- function(pd_flat) {
4145
pd_flat$col3 <- lead(pd_flat$col1, default = tail(pd_flat$col2, 1) + 1L)
4246
pd_flat$col2_nl <- if_else(pd_flat$newlines > 0L,
@@ -54,6 +58,7 @@ remove_attributes <- function(pd_flat, attributes) {
5458
}
5559

5660
#' @describeIn initialize_attributes Initializes `multi_line`.
61+
#' @keywords internal
5762
initialize_multi_line <- function(pd_flat) {
5863
nrow <- nrow(pd_flat)
5964
pd_flat$multi_line <- if_else(pd_flat$terminal,
@@ -64,12 +69,14 @@ initialize_multi_line <- function(pd_flat) {
6469
}
6570

6671
#' @describeIn initialize_attributes Initializes `indention_ref_ind`.
72+
#' @keywords internal
6773
initialize_indention_ref_pos_id <- function(pd_flat) {
6874
pd_flat$indention_ref_pos_id <- NA
6975
pd_flat
7076
}
7177

7278
#' @describeIn initialize_attributes Initializes `indent`.
79+
#' @keywords internal
7380
initialize_indent <- function(pd_flat) {
7481
if (!("indent" %in% names(pd_flat))) {
7582
pd_flat$indent <- 0
@@ -78,6 +85,7 @@ initialize_indent <- function(pd_flat) {
7885
}
7986

8087
#' @describeIn initialize_attributes validates the parse data.
88+
#' @keywords internal
8189
validate_parse_data <- function(pd_flat) {
8290
if (any(pd_flat$spaces < 0L)) {
8391
stop("Invalid parse data")

R/nest.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#' @return A nested parse table. See [tokenize()] for details on the columns
77
#' of the parse table.
88
#' @importFrom purrr when
9+
#' @keywords internal
910
compute_parse_data_nested <- function(text) {
1011
parse_data <- tokenize(text) %>%
1112
add_terminal_token_before() %>%
@@ -25,6 +26,7 @@ compute_parse_data_nested <- function(text) {
2526
#' Map text corresponding to the token "SPECIAL" to a (more) unique token
2627
#' description.
2728
#' @param pd A parse table.
29+
#' @keywords internal
2830
enhance_mapping_special <- function(pd) {
2931
pipes <- pd$token == "SPECIAL" & pd$text == "%>%"
3032
pd$token[pipes] <- special_and("PIPE")
@@ -46,9 +48,11 @@ special_and <- function(text) {
4648
#'
4749
#' @param pd_flat A flat parse table.
4850
#' @name add_token_terminal
51+
#' @keywords internal
4952
NULL
5053

5154
#' @rdname add_token_terminal
55+
#' @keywords internal
5256
add_terminal_token_after <- function(pd_flat) {
5357
terminals <- pd_flat %>%
5458
filter(terminal) %>%
@@ -59,6 +63,7 @@ add_terminal_token_after <- function(pd_flat) {
5963
}
6064

6165
#' @rdname add_token_terminal
66+
#' @keywords internal
6267
add_terminal_token_before <- function(pd_flat) {
6368
terminals <- pd_flat %>%
6469
filter(terminal) %>%
@@ -74,6 +79,7 @@ add_terminal_token_before <- function(pd_flat) {
7479
#' @describeIn add_token_terminal Removes column `terimnal_token_before`. Might
7580
#' be used to prevent the use of invalidated information, e.g. if tokens were
7681
#' added to the nested parse table.
82+
#' @keywords internal
7783
remove_terminal_token_before_and_after <- function(pd_flat) {
7884
pd_flat$token_before <- NULL
7985
pd_flat$token_after <- NULL
@@ -89,6 +95,7 @@ remove_terminal_token_before_and_after <- function(pd_flat) {
8995
#' @return An integer vector of length spaces_after_prefix, which is either
9096
#' one (if `force_one = TRUE`) or `space_after_prefix` with all values
9197
#' below one set to one.
98+
#' @keywords internal
9299
set_spaces <- function(spaces_after_prefix, force_one) {
93100
if (force_one) {
94101
n_of_spaces <- rep(1, length(spaces_after_prefix))
@@ -110,6 +117,7 @@ set_spaces <- function(spaces_after_prefix, force_one) {
110117
#' @seealso [compute_parse_data_nested()]
111118
#' @return A nested parse table.
112119
#' @importFrom purrr map2
120+
#' @keywords internal
113121
nest_parse_data <- function(pd_flat) {
114122
if (all(pd_flat$parent <= 0)) return(pd_flat)
115123
pd_flat$internal <- with(pd_flat, (id %in% parent) | (parent <= 0))
@@ -141,6 +149,7 @@ nest_parse_data <- function(pd_flat) {
141149
#' @details Essentially, this is a wrapper around [dplyr::bind_rows()], but
142150
#' returns `NULL` if the result of [dplyr::bind_rows()] is a data frame with
143151
#' zero rows.
152+
#' @keywords internal
144153
combine_children <- function(child, internal_child) {
145154
bound <- bind_rows(child, internal_child)
146155
if (nrow(bound) == 0) return(NULL)
@@ -152,6 +161,7 @@ combine_children <- function(child, internal_child) {
152161
#' On what line does the first token occur?
153162
#' @param pd_nested A nested parse table.
154163
#' @return The line number on which the first token occurs.
164+
#' @keywords internal
155165
find_start_line <- function(pd_nested) {
156166
pd_nested$line1[1]
157167
}

R/nested_to_tree.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#' @inheritParams create_node_from_nested_root
66
#' @return A data frame.
77
#' @importFrom purrr when
8+
#' @keywords internal
89
create_tree <- function(text, structure_only = FALSE) {
910
compute_parse_data_nested(text) %>%
1011
pre_visit(c(default_style_guide_attributes)) %>%
@@ -28,6 +29,7 @@ create_tree <- function(text, structure_only = FALSE) {
2829
#' initialized <- styler:::pre_visit(nested_pd, c(default_style_guide_attributes))
2930
#' styler:::create_node_from_nested_root(initialized, structure_only = FALSE)
3031
#' }
32+
#' @keywords internal
3133
create_node_from_nested_root <- function(pd_nested, structure_only) {
3234
if (getRversion() < 3.2) stop_insufficient_r_version()
3335
n <- data.tree::Node$new(ifelse(
@@ -42,6 +44,7 @@ create_node_from_nested_root <- function(pd_nested, structure_only) {
4244
#' @inheritParams create_node_from_nested_root
4345
#' @param parent The parent of the node to be created.
4446
#' @importFrom purrr map2 map
47+
#' @keywords internal
4548
create_node_from_nested <- function(pd_nested, parent, structure_only) {
4649
if (is.null(pd_nested)) {
4750
return()

0 commit comments

Comments
 (0)