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
89NULL
910
1011# ' @describeIn update_indention Inserts indention based on round, square and
1112# ' curly brackets.
13+ # ' @keywords internal
1214indent_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
2427indent_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
4448unindent_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
5863indent_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
7278indent_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
8087indent_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
8896indent_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
98107indent_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
141151compute_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
169180needs_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
194206needs_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
225238set_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
237251pd_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
253268update_newlines <- function (pd ) {
254269 npd <- nrow(pd ) - 1
255270 pd $ newlines [seq_len(npd )] <- pd $ lag_newlines [seq_len(npd ) + 1 ]
0 commit comments