diff --git a/DESCRIPTION b/DESCRIPTION index 11ff72e..0e70679 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -23,4 +23,4 @@ Config/testthat/edition: 3 Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.1 +RoxygenNote: 7.3.1 diff --git a/NAMESPACE b/NAMESPACE index 90c06a3..c7512f2 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -19,3 +19,15 @@ export(tidyverse_reindention) export(tidyverse_style) import(styler) importFrom(purrr,partial) +importFrom(styler,cache_activate) +importFrom(styler,cache_clear) +importFrom(styler,cache_deactivate) +importFrom(styler,cache_info) +importFrom(styler,create_style_guide) +importFrom(styler,default_style_guide_attributes) +importFrom(styler,specify_math_token_spacing) +importFrom(styler,specify_reindention) +importFrom(styler,specify_transformers_drop) +importFrom(styler,tidyverse_math_token_spacing) +importFrom(styler,tidyverse_reindention) +importFrom(styler,tidyverse_style) diff --git a/man/add_cache_block.Rd b/man/add_cache_block.Rd deleted file mode 100644 index f9aef34..0000000 --- a/man/add_cache_block.Rd +++ /dev/null @@ -1,16 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/nest.R -\name{add_cache_block} -\alias{add_cache_block} -\title{Add the block id to a parse table} -\usage{ -add_cache_block(pd_nested) -} -\arguments{ -\item{pd_nested}{A top-level nest.} -} -\description{ -Must be after \code{\link[=nest_parse_data]{nest_parse_data()}} because requires a nested parse table as -input. -} -\keyword{internal} diff --git a/man/add_token_terminal.Rd b/man/add_token_terminal.Rd deleted file mode 100644 index 21f352f..0000000 --- a/man/add_token_terminal.Rd +++ /dev/null @@ -1,32 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/nest.R -\name{add_token_terminal} -\alias{add_token_terminal} -\alias{add_terminal_token_after} -\alias{add_terminal_token_before} -\alias{add_attributes_caching} -\title{Add information about previous / next token to each terminal} -\usage{ -add_terminal_token_after(pd_flat) - -add_terminal_token_before(pd_flat) - -add_attributes_caching(pd_flat, transformers, more_specs) -} -\arguments{ -\item{pd_flat}{A flat parse table.} -} -\description{ -Note that this does function must be called in \code{\link[=compute_parse_data_nested]{compute_parse_data_nested()}} -and we cannot wait to initialize this attribute until \code{\link[=apply_transformers]{apply_transformers()}}, -where all other attributes are initialized with -\code{\link[=default_style_guide_attributes]{default_style_guide_attributes()}} (when using \code{\link[=tidyverse_style]{tidyverse_style()}}) because -for cached code, we don't build up the nested structure and leave it shallow -(to speed up things), see also \code{\link[=shallowify]{shallowify()}}. -} -\section{Functions}{ -\itemize{ -\item \code{add_attributes_caching()}: Initializes \code{newlines} and \code{lag_newlines}. - -}} -\keyword{internal} diff --git a/man/combine_children.Rd b/man/combine_children.Rd deleted file mode 100644 index 8e4f68a..0000000 --- a/man/combine_children.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/nest.R -\name{combine_children} -\alias{combine_children} -\title{Combine child and internal child} -\usage{ -combine_children(child, internal_child) -} -\arguments{ -\item{child}{A parse table or \code{NULL}.} - -\item{internal_child}{A parse table or \code{NULL}.} -} -\description{ -Binds two parse tables together and arranges them so that the tokens are in -the correct order. -} -\details{ -Essentially, this is a wrapper around vctrs::vec_rbind()], but -returns \code{NULL} if the result of vctrs::vec_rbind()] is a data frame with -zero rows. -} -\keyword{internal} diff --git a/man/compute_parse_data_nested.Rd b/man/compute_parse_data_nested.Rd deleted file mode 100644 index 579f250..0000000 --- a/man/compute_parse_data_nested.Rd +++ /dev/null @@ -1,28 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/nest.R -\name{compute_parse_data_nested} -\alias{compute_parse_data_nested} -\title{Obtain a nested parse table from a character vector} -\usage{ -compute_parse_data_nested( - text, - transformers = tidyverse_style(), - more_specs = NULL -) -} -\value{ -A nested parse table. See \code{\link[=tokenize]{tokenize()}} for details on the columns -of the parse table. -} -\description{ -Parses \code{text} to a flat parse table and subsequently changes its -representation into a nested parse table with \code{\link[=nest_parse_data]{nest_parse_data()}}. -} -\examples{ -code <- " -ab <- 1L # some comment -abcdef <- 2L -" -writeLines(code) -compute_parse_data_nested(code) -} diff --git a/man/contains_else_expr_that_needs_braces.Rd b/man/contains_else_expr_that_needs_braces.Rd deleted file mode 100644 index f17990b..0000000 --- a/man/contains_else_expr_that_needs_braces.Rd +++ /dev/null @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/expr-is.R -\name{contains_else_expr_that_needs_braces} -\alias{contains_else_expr_that_needs_braces} -\title{Check whether an else expression needs braces} -\usage{ -contains_else_expr_that_needs_braces(pd) -} -\arguments{ -\item{pd}{A parse table} -} -\description{ -Checks whether an else expression in a nest needs braces. Note that for -if-else-if expressions, there is no need to add braces since the if in -else-if will be visited separately with the visitor. This applies to all -conditional statements with more than one alternative. -} -\keyword{internal} diff --git a/man/enhance_mapping_special.Rd b/man/enhance_mapping_special.Rd deleted file mode 100644 index 244e16f..0000000 --- a/man/enhance_mapping_special.Rd +++ /dev/null @@ -1,16 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/nest.R -\name{enhance_mapping_special} -\alias{enhance_mapping_special} -\title{Enhance the mapping of text to the token "SPECIAL"} -\usage{ -enhance_mapping_special(pd) -} -\arguments{ -\item{pd}{A parse table.} -} -\description{ -Map text corresponding to the token "SPECIAL" to a (more) unique token -description. -} -\keyword{internal} diff --git a/man/find_line_break_position_in_multiline_call.Rd b/man/find_line_break_position_in_multiline_call.Rd deleted file mode 100644 index 3efe976..0000000 --- a/man/find_line_break_position_in_multiline_call.Rd +++ /dev/null @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rules-line-breaks.R -\name{find_line_break_position_in_multiline_call} -\alias{find_line_break_position_in_multiline_call} -\title{Find index of the token before which the line should be broken} -\usage{ -find_line_break_position_in_multiline_call(pd) -} -\arguments{ -\item{pd}{A parse table.} -} -\description{ -Given a multi-line function call parse table, this function finds the -position of the first named argument and breaks returns the index of it. -If there is no named argument, the line is broken right after the opening -parenthesis. -} -\keyword{internal} diff --git a/man/find_pos_id_to_keep.Rd b/man/find_pos_id_to_keep.Rd deleted file mode 100644 index 8d4324d..0000000 --- a/man/find_pos_id_to_keep.Rd +++ /dev/null @@ -1,35 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/nest.R -\name{find_pos_id_to_keep} -\alias{find_pos_id_to_keep} -\title{Find the pos ids to keep} -\usage{ -find_pos_id_to_keep(pd) -} -\arguments{ -\item{pd}{A temporary top-level nest where the first expression is always a -top-level expression, potentially cached.} -} -\description{ -To make a parse table shallow, we must know which ids to keep. -\code{split(cumsum(pd_parent_first$parent == 0L))} above puts comments with -negative parents in the same block as proceeding expressions (but also with -positive). -\code{find_pos_id_to_keep()} must hence always keep negative comments. We did not -use \code{split(cumsum(pd_parent_first$parent < 1L))} because then every top-level -comment is an expression on its own and processing takes much longer for -typical roxygen annotated code. -} -\details{ -Note that top-level comments \strong{above} code have negative parents -(the negative value of the parent of the code expression that follows after, -another comment might be in the way though), all comments that are not top -level have positive ids. All comments for which no code follows afterwards -have parent 0. -} -\examples{ -styler:::get_parse_data(c("#", "1")) -styler:::get_parse_data(c("c(#", "1)")) -styler:::get_parse_data(c("", "c(#", "1)", "#")) -} -\keyword{internal} diff --git a/man/fix_quotes.Rd b/man/fix_quotes.Rd deleted file mode 100644 index ab0586b..0000000 --- a/man/fix_quotes.Rd +++ /dev/null @@ -1,22 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rules-tokens.R -\name{fix_quotes} -\alias{fix_quotes} -\title{Replace single quotes with double quotes} -\usage{ -fix_quotes(pd_flat) -} -\arguments{ -\item{pd_flat}{A flat parse table.} -} -\description{ -We do not use \code{deparse()} as in previous implementations but \code{paste0()} since -the former approach escapes the reverse backslash in the line break character -\verb{\\\\n} whereas the solution with \code{paste0()} does not. -} -\examples{ -style_text("'here -is a string -'") -} -\keyword{internal} diff --git a/man/if_for_while_part_requires_braces.Rd b/man/if_for_while_part_requires_braces.Rd deleted file mode 100644 index a6f1d67..0000000 --- a/man/if_for_while_part_requires_braces.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rules-tokens.R -\name{if_for_while_part_requires_braces} -\alias{if_for_while_part_requires_braces} -\title{Check if if, for or while loop expression require a braces.} -\usage{ -if_for_while_part_requires_braces(pd, key_token) -} -\arguments{ -\item{pd}{A parse table.} - -\item{key_token}{The token that comes right before the token that contains -the expression to be wrapped (ignoring comments). For if and while loops, -this is the closing "')'", for a for-loop it's "forcond".} -} -\description{ -This is the case if they are multi-line and not yet wrapped into curly -braces. -} -\keyword{internal} diff --git a/man/is_code_chunk_header_or_xaringan_or_code_output.Rd b/man/is_code_chunk_header_or_xaringan_or_code_output.Rd deleted file mode 100644 index 04eb145..0000000 --- a/man/is_code_chunk_header_or_xaringan_or_code_output.Rd +++ /dev/null @@ -1,26 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/expr-is.R -\name{is_code_chunk_header_or_xaringan_or_code_output} -\alias{is_code_chunk_header_or_xaringan_or_code_output} -\title{Identify spinning code chunk header or xaringan} -\usage{ -is_code_chunk_header_or_xaringan_or_code_output(pd) -} -\arguments{ -\item{pd}{A parse table.} -} -\description{ -Wrongly identifies a comment without a preceding line break as a code chunk -header. -See https://yihui.name/knitr/demo/stitch/#spin-comment-out-texts for details. -} -\examples{ -style_text(c( - "# title", - "some_code <- function() {}", - "#+ chunk-label, opt1=value1", - "call(3, 2, c(3:2))", - "#> 99" -)) -} -\keyword{internal} diff --git a/man/is_shebang.Rd b/man/is_shebang.Rd deleted file mode 100644 index f3c053e..0000000 --- a/man/is_shebang.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/expr-is.R -\name{is_shebang} -\alias{is_shebang} -\title{Identify comments that are shebangs} -\usage{ -is_shebang(pd) -} -\arguments{ -\item{pd}{A parse table.} -} -\description{ -Shebangs should be preserved and no space should be inserted between -\verb{#} and \code{!}. A comment is a shebang if it is the first top-level token -(identified with \code{pos_id}) and if it starts with \verb{#!}. -} -\examples{ -style_text("#!/usr/bin/env Rscript") -} -\keyword{internal} diff --git a/man/lookup_new_special.Rd b/man/lookup_new_special.Rd deleted file mode 100644 index 0dfb87f..0000000 --- a/man/lookup_new_special.Rd +++ /dev/null @@ -1,15 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/token-define.R -\name{lookup_new_special} -\alias{lookup_new_special} -\title{Lookup which new tokens were created from "SPECIAL"} -\usage{ -lookup_new_special(regex = NA) -} -\arguments{ -\item{regex}{A regular expression pattern to search for.} -} -\description{ -Lookup which new tokens were created from "SPECIAL" -} -\keyword{internal} diff --git a/man/lookup_tokens.Rd b/man/lookup_tokens.Rd deleted file mode 100644 index ad8c4c9..0000000 --- a/man/lookup_tokens.Rd +++ /dev/null @@ -1,12 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/token-define.R -\name{lookup_tokens} -\alias{lookup_tokens} -\title{Lookup all tokens that have a unique token-text mapping} -\usage{ -lookup_tokens() -} -\description{ -Lookup all tokens that have a unique token-text mapping -} -\keyword{internal} diff --git a/man/nest_parse_data.Rd b/man/nest_parse_data.Rd deleted file mode 100644 index 228fe40..0000000 --- a/man/nest_parse_data.Rd +++ /dev/null @@ -1,26 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/nest.R -\name{nest_parse_data} -\alias{nest_parse_data} -\title{Nest a flat parse table} -\usage{ -nest_parse_data(pd_flat) -} -\arguments{ -\item{pd_flat}{A flat parse table including both terminals and non-terminals.} -} -\value{ -A nested parse table. -} -\description{ -\code{nest_parse_data} groups \code{pd_flat} into a parse table with tokens that are -a parent to other tokens (called internal) and such that are not (called -child). Then, the token in child are joined to their parents in internal -and all token information of the children is nested into a column "child". -This is done recursively until we are only left with a nested data frame that -contains one row: The nested parse table. -} -\seealso{ -\code{\link[=compute_parse_data_nested]{compute_parse_data_nested()}} -} -\keyword{internal} diff --git a/man/pd_is.Rd b/man/pd_is.Rd deleted file mode 100644 index 572fe6b..0000000 --- a/man/pd_is.Rd +++ /dev/null @@ -1,114 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/expr-is.R -\name{pd_is} -\alias{pd_is} -\alias{is_curly_expr} -\alias{is_for_expr} -\alias{is_conditional_expr} -\alias{is_while_expr} -\alias{is_function_call} -\alias{is_function_declaration} -\alias{is_comment} -\alias{is_tilde_expr} -\alias{is_asymmetric_tilde_expr} -\alias{is_symmetric_tilde_expr} -\title{What is a parse table representing?} -\usage{ -is_curly_expr(pd) - -is_for_expr(pd) - -is_conditional_expr(pd) - -is_while_expr(pd) - -is_function_call(pd) - -is_function_declaration(pd) - -is_comment(pd) - -is_tilde_expr(pd, tilde_pos = c(1L, 2L)) - -is_asymmetric_tilde_expr(pd) - -is_symmetric_tilde_expr(pd) -} -\arguments{ -\item{pd}{A parse table.} - -\item{tilde_pos}{Integer vector indicating row-indices that should be -checked for tilde. See 'Details'.} -} -\description{ -Check whether a parse table corresponds to a certain expression. -} -\details{ -A tilde is on the top row in the parse table if it is an asymmetric tilde -expression (like \code{~column}), in the second row if it is a symmetric tilde -expression (like \code{a~b}). -} -\section{Functions}{ -\itemize{ -\item \code{is_curly_expr()}: Checks whether \code{pd} contains an expression wrapped in curly brackets. - -\item \code{is_for_expr()}: Checks whether \code{pd} contains a \code{for} loop. - -\item \code{is_conditional_expr()}: Checks whether \code{pd} contains is a conditional expression. - -\item \code{is_while_expr()}: Checks whether \code{pd} contains a \code{while} loop. - -\item \code{is_function_call()}: Checks whether \code{pd} is a function call. - -\item \code{is_function_declaration()}: Checks whether \code{pd} is a function declaration. - -\item \code{is_comment()}: Checks for every token whether or not it is a comment. - -\item \code{is_tilde_expr()}: Checks whether \code{pd} contains a tilde. - -\item \code{is_asymmetric_tilde_expr()}: If \code{pd} contains a tilde, checks whether it is asymmetrical. - -\item \code{is_symmetric_tilde_expr()}: If \code{pd} contains a tilde, checks whether it is symmetrical. - -}} -\examples{ -code <- "if (TRUE) { 1 }" -pd <- compute_parse_data_nested(code) -is_curly_expr(pd) -child_of_child <- pd$child[[1]]$child[[5]] -is_curly_expr(child_of_child) - -code <- "for (i in 1:5) print(1:i)" -pd <- compute_parse_data_nested(code) -is_for_expr(pd) -is_for_expr(pd$child[[1]]) - -code <- "if (TRUE) x <- 1 else x <- 0" -pd <- compute_parse_data_nested(code) -is_conditional_expr(pd) -is_conditional_expr(pd$child[[1]]) - -code <- "x <- list(1:3)" -pd <- compute_parse_data_nested(code) -is_function_call(pd) -child_of_child <- pd$child[[1]]$child[[3]] -is_function_call(child_of_child) - -code <- "foo <- function() NULL" -pd <- compute_parse_data_nested(code) -is_function_declaration(pd) -child_of_child <- pd$child[[1]]$child[[3]] -is_function_declaration(child_of_child) - -code <- "x <- 1 # TODO: check value" -pd <- compute_parse_data_nested(code) -is_comment(pd) - -code <- "lm(wt ~ mpg, mtcars)" -pd <- compute_parse_data_nested(code) -is_tilde_expr(pd$child[[1]]$child[[3]]) -is_symmetric_tilde_expr(pd$child[[1]]$child[[3]]) -is_asymmetric_tilde_expr(pd$child[[1]]$child[[3]]) - -} -\concept{third-party style guide helpers} diff --git a/man/set_line_break_after_opening_if_call_is_multi_line.Rd b/man/set_line_break_after_opening_if_call_is_multi_line.Rd deleted file mode 100644 index 417c04a..0000000 --- a/man/set_line_break_after_opening_if_call_is_multi_line.Rd +++ /dev/null @@ -1,31 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rules-line-breaks.R -\name{set_line_break_after_opening_if_call_is_multi_line} -\alias{set_line_break_after_opening_if_call_is_multi_line} -\title{Sets line break after opening parenthesis} -\usage{ -set_line_break_after_opening_if_call_is_multi_line( - pd, - except_token_after = NULL, - except_text_before = NULL, - force_text_before = NULL -) -} -\description{ -Sets line break after opening parenthesis -} -\details{ -In general, every call that is multi-line has a line break after the opening -parenthesis. Exceptions: -\itemize{ -\item The token right after the parenthesis is a comment, then, the line should -be broken after the comment only. Governed by \code{except_token_after}. -\item The name of the function called is \code{ifelse()} or similar, where we can -allow the condition on the same line as the function name, and we don't -impose rules on the line breaks for the subsequent arguments. Governed -by \code{except_text_before}. -\item Some calls like \code{switch()} statements are always forced to become multi- -line. Governed by \code{force_text_before}. -} -} -\keyword{internal} diff --git a/man/set_line_break_around_curly_curly.Rd b/man/set_line_break_around_curly_curly.Rd deleted file mode 100644 index 06fd2fa..0000000 --- a/man/set_line_break_around_curly_curly.Rd +++ /dev/null @@ -1,48 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rules-line-breaks.R, R/rules-spaces.R -\name{set_line_break_around_curly_curly} -\alias{set_line_break_around_curly_curly} -\alias{set_space_in_curly_curly} -\title{Styling around \verb{\\\{\\\{}} -\usage{ -set_line_break_around_curly_curly(pd) - -set_space_in_curly_curly(pd) -} -\arguments{ -\item{pd}{A parse table.} -} -\description{ -With \{rlang\} version 0.4, a new syntactic sugar is introduced, the -curly-curly operator. It interprets this code in a special way: -\verb{call(\\\{\\\{ x \\\}\\\})}. See this -\href{https://www.tidyverse.org/blog/2019/06/rlang-0-4-0/}{blog post} -on the topic. Here, the curly-curly sugar is understood as two opening -curly braces, followed by an expression followed by two closing curly braces, -e.g. \verb{\\\{\\\{1\\\}\\\}}. \verb{\\\{\\\{1\\\} + 1\\\}} does not contain the curly-curly syntactic -sugar according to the above definition. On the other hand \verb{\\\{\\\{ x + y \\\}\\\}} -is recognized by styler as containing it (and is parsable code) -but will most likely give an error at runtime because the way the syntactic -sugar is defined in rlang is to use a single token within curly-curly. In -addition, because rlang parses \verb{\\\{\\\{} in a special way (just as \verb{!!}), the -expression \verb{\\\{\\\{ x \\\}\\\}} will give a runtime error when used outside of a -context that is capable of handling it, e.g. on the top-level (that is, not -within function call like \verb{rlang_fun(\\\{\\\{ x \\\}\\\})}) or within a base R -function such as \code{\link[=c]{c()}}. However, these differences are assumed to be -irrelevant for styling curly-curly, as much as they were for styling \verb{!!}. -curly-curly affects styling of line break and spaces, namely: -} -\details{ -\itemize{ -\item No line break after first or second \verb{\\\{}, before third and fourth \verb{\\\{}. -\item No space after first and third \verb{\\\{}, one space after second and before -third \verb{\\\}}. -\item No line breaks within curly-curly, e.g. \verb{\\\{\\\{ x \\\}\\\}} can only contain line -breaks after the last brace or before the first brace. But these are not -dependent on curly-curly specifically. -} -} -\seealso{ -style_text_without_curly_curly -} -\keyword{internal} diff --git a/man/set_line_break_before_curly_opening.Rd b/man/set_line_break_before_curly_opening.Rd deleted file mode 100644 index c590b58..0000000 --- a/man/set_line_break_before_curly_opening.Rd +++ /dev/null @@ -1,66 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rules-line-breaks.R -\name{set_line_break_before_curly_opening} -\alias{set_line_break_before_curly_opening} -\title{Set line break before a curly brace} -\usage{ -set_line_break_before_curly_opening(pd) -} -\description{ -Rule: -\itemize{ -\item Principle: Function arguments that consist of a braced expression always -need to start on a new line -\item Exception: \link{...} unless it's the last argument and all other -arguments fit on the line of the function call -\item Exception: \link{...} or they are named. -\item Extension: Also, expressions following on braced expressions also cause a -line trigger. -} -} -\examples{ -\dontshow{if (FALSE) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -tryCatch( - { - f(8) - }, - error = function(e) NULL -) -# last-argument case -testthat("braces braces are cool", { - code(to = execute) -}) -call2( - x = 2, { - code(to = execute) - }, - c = { - # this is the named case - g(x = 7) - } -) -tryGugus( - { - g5(k = na) - }, - a + b # line break also here because - # preceded by brace expression -) - -# brace expressions go on new line if part of a pipe, in function call... -c( - data \%>\% - filter(bar) \%>\% - { - cor(.$col1, .$col2, use = "complete.obs") - } -) -# ... or outside -data \%>\% - filter(bar) \%>\% - { - cor(.$col1, .$col2, use = "complete.obs") - } -\dontshow{\}) # examplesIf} -} -\keyword{internal} diff --git a/man/set_line_break_if_call_is_multi_line.Rd b/man/set_line_break_if_call_is_multi_line.Rd deleted file mode 100644 index a8482a3..0000000 --- a/man/set_line_break_if_call_is_multi_line.Rd +++ /dev/null @@ -1,37 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rules-line-breaks.R -\name{set_line_break_if_call_is_multi_line} -\alias{set_line_break_if_call_is_multi_line} -\alias{set_line_break_before_closing_call} -\alias{remove_line_break_in_fun_call} -\title{Set line break for multi-line function calls} -\usage{ -set_line_break_before_closing_call(pd, except_token_before) - -remove_line_break_in_fun_call(pd, strict) -} -\arguments{ -\item{pd}{A parse table.} - -\item{except_token_before}{A character vector with text before "')'" that do -not cause a line break before "')'".} - -\item{except_token_after}{A character vector with tokens after "'('" that do -not cause a line break after "'('".} - -\item{except_text_before}{A character vector with text before "'('" that do -not cause a line break after "'('".} - -\item{force_text_before}{A character vector with text before "'('" that -forces a line break after every argument in the call.} -} -\description{ -Set line break for multi-line function calls -} -\section{Functions}{ -\itemize{ -\item \code{set_line_break_before_closing_call()}: Sets line break before -closing parenthesis. - -}} -\keyword{internal} diff --git a/man/set_space_around_op.Rd b/man/set_space_around_op.Rd deleted file mode 100644 index c3a4502..0000000 --- a/man/set_space_around_op.Rd +++ /dev/null @@ -1,12 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rules-spaces.R -\name{set_space_around_op} -\alias{set_space_around_op} -\title{Set spaces around operators} -\usage{ -set_space_around_op(pd_flat, strict) -} -\description{ -Alignment is kept, if detected. -} -\keyword{internal} diff --git a/man/set_space_between_eq_sub_and_comma.Rd b/man/set_space_between_eq_sub_and_comma.Rd deleted file mode 100644 index f0a8677..0000000 --- a/man/set_space_between_eq_sub_and_comma.Rd +++ /dev/null @@ -1,15 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rules-spaces.R -\name{set_space_between_eq_sub_and_comma} -\alias{set_space_between_eq_sub_and_comma} -\title{Set space between \code{EQ_SUB} and \code{"','"}} -\usage{ -set_space_between_eq_sub_and_comma(pd) -} -\arguments{ -\item{pd}{A parse table.} -} -\description{ -Set space between \code{EQ_SUB} and \code{"','"} -} -\keyword{internal} diff --git a/man/set_space_between_levels.Rd b/man/set_space_between_levels.Rd deleted file mode 100644 index 7f6244b..0000000 --- a/man/set_space_between_levels.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rules-spaces.R -\name{set_space_between_levels} -\alias{set_space_between_levels} -\title{Set space between levels of nesting} -\usage{ -set_space_between_levels(pd_flat) -} -\arguments{ -\item{pd_flat}{A flat parse table.} -} -\description{ -With the nested approach, certain rules do not have an effect anymore because -of the nature of the nested structure. Setting spacing before curly -brackets in for / if / while statements and function declarations will be -such a case since a curly bracket is always at the first position in a parse -table, so spacing cannot be set after the previous token. -} -\keyword{internal} diff --git a/man/set_spaces.Rd b/man/set_spaces.Rd deleted file mode 100644 index ecbcae9..0000000 --- a/man/set_spaces.Rd +++ /dev/null @@ -1,26 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/nest.R -\name{set_spaces} -\alias{set_spaces} -\title{Helper for setting spaces} -\usage{ -set_spaces(spaces_after_prefix, force_one) -} -\arguments{ -\item{spaces_after_prefix}{An integer vector with the number of spaces -after the prefix.} - -\item{force_one}{Whether spaces_after_prefix should be set to one in all -cases.} -} -\value{ -An integer vector of length spaces_after_prefix, which is either -one (if \code{force_one = TRUE}) or \code{space_after_prefix} with all values -below one set to one. - -Numeric vector indicating the number of spaces. -} -\description{ -Helper for setting spaces -} -\keyword{internal} diff --git a/man/set_unindention_child.Rd b/man/set_unindention_child.Rd deleted file mode 100644 index b322bde..0000000 --- a/man/set_unindention_child.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/unindent.R -\name{set_unindention_child} -\alias{set_unindention_child} -\title{Unindent a child if necessary} -\usage{ -set_unindention_child(pd, token = "')'", unindent_by) -} -\arguments{ -\item{pd}{A parse table.} - -\item{token}{The token the unindention should be based on.} - -\item{unindent_by}{By how many spaces one level of indention is reversed.} -} -\description{ -check whether any of the children of \code{pd} has \code{token} on the same line as the -closing \code{token} of pd. If so, unindent that token. -} -\keyword{internal} diff --git a/man/shallowify.Rd b/man/shallowify.Rd deleted file mode 100644 index 52d763e..0000000 --- a/man/shallowify.Rd +++ /dev/null @@ -1,40 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/nest.R -\name{shallowify} -\alias{shallowify} -\title{Shallowify the parse table} -\usage{ -shallowify(pd) -} -\description{ -Cached expressions don't need to be transformed with \code{transformers} in -\code{\link[=parse_transform_serialize_r_block]{parse_transform_serialize_r_block()}}, we simply return \code{text} for the -top-level token. -} -\details{ -Expressions that are cached are already styled correctly. We can make the -parse table shallow at these locations, fully relying on the \code{text} column: -\itemize{ -\item remove all children, as they are not needed anymore. -\item mark the expression as a terminal. -} -} -\section{Top-level comments}{ - -Note that we do not cache top-level comments. Because package code has a lot -of roxygen comments and each of them is a top-level expression, checking is -very expensive. More expensive than styling, because comments are always -terminals. This will also yield large speed improvements in -\code{\link[=compute_parse_data_nested]{compute_parse_data_nested()}} because nesting is expensive and will not be -done for cached expressions. -} - -\section{Implementation}{ - -Because the structure of the parse table is not always "top-level expression -first, then children", this function creates a temporary parse table that has -this property and then extract the ids and subset the original parse table so -it is shallow in the right places. -} - -\keyword{internal} diff --git a/man/start_comments_with_space.Rd b/man/start_comments_with_space.Rd deleted file mode 100644 index 03af11a..0000000 --- a/man/start_comments_with_space.Rd +++ /dev/null @@ -1,30 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rules-spaces.R -\name{start_comments_with_space} -\alias{start_comments_with_space} -\title{Start comments with a space} -\usage{ -start_comments_with_space(pd, force_one = FALSE) -} -\arguments{ -\item{pd}{A parse table.} - -\item{force_one}{Whether or not to force one space or allow multiple spaces.} -} -\description{ -Forces comments to start with a space, that is, after the regular expression -\verb{#+['\\\\*]}, at least one space must follow if the comment is \emph{non-empty}, i.e -there is not just spaces within the comment. Multiple spaces may be legit for -indention in some situations. -} -\section{Exceptions}{ - -Spaces won't be added to comments when they are: -\itemize{ -\item shebangs -\item code chunk headers -\item xaringan markers -} -} - -\keyword{internal} diff --git a/man/style_dir.Rd b/man/style_dir.Rd index 2c3ec18..b53d873 100644 --- a/man/style_dir.Rd +++ b/man/style_dir.Rd @@ -21,10 +21,11 @@ style_dir( \arguments{ \item{path}{Path to a directory with files to transform.} -\item{...}{Arguments passed on to the \code{style} function.} +\item{...}{Arguments passed on to the \code{style} function, +see \code{\link[styler:tidyverse_style]{tidyverse_style()}} for the default argument.} \item{style}{A function that creates a style guide to use, by default -\code{\link[styler:tidyverse_style]{tidyverse_style()}} (without the parentheses). Not used +\code{\link[styler]{tidyverse_style}}. Not used further except to construct the argument \code{transformers}. See \code{\link[styler:style_guides]{style_guides()}} for details.} @@ -33,12 +34,12 @@ conveniently constructed via the \code{style} argument and \code{...}. See 'Examples'.} \item{filetype}{Vector of file extensions indicating which file types should -be styled. Case is ignored, and the \code{.} is optional, e.g. -\code{c(".R", ".Rmd")}, or \code{c("r", "rmd")}. Supported values (after -standardization) are: "r", "rprofile", "rmd", "rmarkdown", "rnw". Rmarkdown is treated as Rmd.} +be styled. Case is ignored, and the \code{.} is optional, e.g. \code{c(".R", ".Rmd")}, or \code{c("r", "rmd")}. Supported values (after standardization) are: +"r", "rprofile", "rmd", "rmarkdown", "rnw", "qmd". Rmarkdown is treated as +Rmd.} -\item{recursive}{A logical value indicating whether or not files in subdirectories -of \code{path} should be styled as well.} +\item{recursive}{A logical value indicating whether or not files in +sub directories of \code{path} should be styled as well.} \item{exclude_files}{Character vector with paths to files that should be excluded from styling.} diff --git a/man/style_file.Rd b/man/style_file.Rd index 09a0f49..e819e23 100644 --- a/man/style_file.Rd +++ b/man/style_file.Rd @@ -15,12 +15,14 @@ style_file( ) } \arguments{ -\item{path}{A character vector with paths to files to style.} +\item{path}{A character vector with paths to files to style. Supported +extensions: \code{.R}, \code{.Rmd}, \code{.Rmarkdown}, \code{.qmd} and \code{.Rnw}.} -\item{...}{Arguments passed on to the \code{style} function.} +\item{...}{Arguments passed on to the \code{style} function, +see \code{\link[styler:tidyverse_style]{tidyverse_style()}} for the default argument.} \item{style}{A function that creates a style guide to use, by default -\code{\link[styler:tidyverse_style]{tidyverse_style()}} (without the parentheses). Not used +\code{\link[styler]{tidyverse_style}}. Not used further except to construct the argument \code{transformers}. See \code{\link[styler:style_guides]{style_guides()}} for details.} diff --git a/man/style_pkg.Rd b/man/style_pkg.Rd index 8907f5d..eee5522 100644 --- a/man/style_pkg.Rd +++ b/man/style_pkg.Rd @@ -20,10 +20,11 @@ style_pkg( \arguments{ \item{pkg}{Path to a (subdirectory of an) R package.} -\item{...}{Arguments passed on to the \code{style} function.} +\item{...}{Arguments passed on to the \code{style} function, +see \code{\link[styler:tidyverse_style]{tidyverse_style()}} for the default argument.} \item{style}{A function that creates a style guide to use, by default -\code{\link[styler:tidyverse_style]{tidyverse_style()}} (without the parentheses). Not used +\code{\link[styler]{tidyverse_style}}. Not used further except to construct the argument \code{transformers}. See \code{\link[styler:style_guides]{style_guides()}} for details.} @@ -32,9 +33,9 @@ conveniently constructed via the \code{style} argument and \code{...}. See 'Examples'.} \item{filetype}{Vector of file extensions indicating which file types should -be styled. Case is ignored, and the \code{.} is optional, e.g. -\code{c(".R", ".Rmd")}, or \code{c("r", "rmd")}. Supported values (after -standardization) are: "r", "rprofile", "rmd", "rmarkdown", "rnw". Rmarkdown is treated as Rmd.} +be styled. Case is ignored, and the \code{.} is optional, e.g. \code{c(".R", ".Rmd")}, or \code{c("r", "rmd")}. Supported values (after standardization) are: +"r", "rprofile", "rmd", "rmarkdown", "rnw", "qmd". Rmarkdown is treated as +Rmd.} \item{exclude_files}{Character vector with paths to files that should be excluded from styling.} diff --git a/man/style_space_around_math_token.Rd b/man/style_space_around_math_token.Rd deleted file mode 100644 index b994041..0000000 --- a/man/style_space_around_math_token.Rd +++ /dev/null @@ -1,24 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rules-spaces.R -\name{style_space_around_math_token} -\alias{style_space_around_math_token} -\title{Style spacing around math tokens} -\usage{ -style_space_around_math_token(strict, zero, one, pd_flat) -} -\arguments{ -\item{strict}{Whether the rules should be applied strictly or not.} - -\item{zero}{Character vector of tokens that should be surrounded with zero -spaces.} - -\item{one}{Character vector with tokens that should be surrounded by at -least one space (depending on \code{strict = TRUE} in the styling functions -\code{\link[=style_text]{style_text()}} and friends). See 'Examples'.} - -\item{pd_flat}{A nest or a flat parse table.} -} -\description{ -Style spacing around math tokens -} -\keyword{internal} diff --git a/man/style_space_around_token.Rd b/man/style_space_around_token.Rd deleted file mode 100644 index 50f6163..0000000 --- a/man/style_space_around_token.Rd +++ /dev/null @@ -1,30 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rules-spaces.R -\name{style_space_around_token} -\alias{style_space_around_token} -\title{Set spacing of token to a certain level} -\usage{ -style_space_around_token( - pd_flat, - strict, - tokens, - level_before, - level_after = level_before -) -} -\arguments{ -\item{pd_flat}{A nest or a flat parse table.} - -\item{strict}{Whether the rules should be applied strictly or not.} - -\item{tokens}{Character vector with tokens that should be styled.} - -\item{level_before, level_after}{Scalar indicating the amount of spaces that -should be inserted around the \code{tokens} on the left and right position -respectively.} -} -\description{ -Set the spacing of all \code{tokens} in \code{pd_flat} to \code{level} if \code{strict = TRUE} or -to at least to \code{level} if \code{strict = FALSE}. -} -\keyword{internal} diff --git a/man/style_text.Rd b/man/style_text.Rd index 19504a4..8c05fa0 100644 --- a/man/style_text.Rd +++ b/man/style_text.Rd @@ -16,10 +16,11 @@ style_text( \arguments{ \item{text}{A character vector with text to style.} -\item{...}{Arguments passed on to the \code{style} function.} +\item{...}{Arguments passed on to the \code{style} function, +see \code{\link[styler:tidyverse_style]{tidyverse_style()}} for the default argument.} \item{style}{A function that creates a style guide to use, by default -\code{\link[styler:tidyverse_style]{tidyverse_style()}} (without the parentheses). Not used +\code{\link[styler]{tidyverse_style}}. Not used further except to construct the argument \code{transformers}. See \code{\link[styler:style_guides]{style_guides()}} for details.} diff --git a/man/stylerignore.Rd b/man/stylerignore.Rd deleted file mode 100644 index f435636..0000000 --- a/man/stylerignore.Rd +++ /dev/null @@ -1,62 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/nest.R -\name{stylerignore} -\alias{stylerignore} -\title{Turn off styling for parts of the code} -\description{ -Using stylerignore markers, you can temporarily turn off styler. Beware that -for \verb{styler > 1.2.0}, some alignment is -\href{https://styler.r-lib.org/articles/detect-alignment.html}{detected by styler}, -making stylerignore redundant. See a few illustrative examples below. -} -\details{ -Styling is on for all lines by default when you run styler. -\itemize{ -\item To mark the start of a sequence where you want to turn styling off, use -\verb{# styler: off}. -\item To mark the end of this sequence, put \verb{# styler: on} in your code. After -that line, styler will again format your code. -\item To ignore an inline statement (i.e. just one line), place \verb{# styler: off} -at the end of the line. -To use something else as start and stop markers, set the R options -\code{styler.ignore_start} and -\code{styler.ignore_stop} using \code{\link[=options]{options()}}. For styler version > 1.6.2, the -option supports character vectors longer than one and the marker are not -exactly matched, but using a regular expression, which means you can have -multiple marker on one line, e.g. \verb{# nolint start styler: off}. -} -} -\examples{ -# as long as the order of the markers is correct, the lines are ignored. -style_text( - " - 1+1 - # styler: off - 1+1 - # styler: on - 1+1 - " -) - -# if there is a stop marker before a start marker, styler won't be able -# to figure out which lines you want to ignore and won't ignore anything, -# issuing a warning. -\dontrun{ -style_text( - " - 1+1 - # styler: off - 1+1 - # styler: off - 1+1 - " -) -} -# some alignment of code is detected, so you don't need to use stylerignore -style_text( - "call( - xyz = 3, - x = 11 - )" -) -} diff --git a/man/text_to_flat_pd.Rd b/man/text_to_flat_pd.Rd deleted file mode 100644 index c7534a7..0000000 --- a/man/text_to_flat_pd.Rd +++ /dev/null @@ -1,24 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/nest.R -\name{text_to_flat_pd} -\alias{text_to_flat_pd} -\title{Creates a flat parse table with minimal initialization} -\usage{ -text_to_flat_pd(text, transformers, more_specs) -} -\description{ -Creates a flat parse table with minimal initialization and makes the parse -table shallow where appropriate. -} -\details{ -This includes: -\itemize{ -\item token before and after. -\item stylerignore attribute. -\item caching attributes. -} - -Note that the parse table might be shallow if caching is enabled and some -values are cached. -} -\keyword{internal} diff --git a/man/unindent_child.Rd b/man/unindent_child.Rd deleted file mode 100644 index 2ab7c9f..0000000 --- a/man/unindent_child.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/unindent.R -\name{unindent_child} -\alias{unindent_child} -\title{Unindent a child} -\usage{ -unindent_child(pd, token = c("')'", "'}'"), unindent_by = 2L) -} -\arguments{ -\item{pd}{A parse table.} - -\item{token}{The token the unindention should be based on.} - -\item{unindent_by}{By how many spaces one level of indention is reversed.} -} -\description{ -Unindent a child -} -\keyword{internal} diff --git a/man/wrap_else_multiline_curly.Rd b/man/wrap_else_multiline_curly.Rd deleted file mode 100644 index c3e120b..0000000 --- a/man/wrap_else_multiline_curly.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rules-tokens.R -\name{wrap_else_multiline_curly} -\alias{wrap_else_multiline_curly} -\title{Add curly braces to else} -\usage{ -wrap_else_multiline_curly(pd, indent_by = 2L, space_after = 0L) -} -\arguments{ -\item{pd}{A parse table.} - -\item{indent_by}{The amount of spaces used to indent an expression in curly -braces. Used for unindention.} -} -\description{ -Wrap the else part of a conditional expression into curly braces if not -already wrapped into a such. -} -\keyword{internal} diff --git a/man/wrap_if_else_while_for_fun_multi_line_in_curly.Rd b/man/wrap_if_else_while_for_fun_multi_line_in_curly.Rd deleted file mode 100644 index 29b7c06..0000000 --- a/man/wrap_if_else_while_for_fun_multi_line_in_curly.Rd +++ /dev/null @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rules-tokens.R -\name{wrap_if_else_while_for_fun_multi_line_in_curly} -\alias{wrap_if_else_while_for_fun_multi_line_in_curly} -\title{Wrap if-else, while and for statements in curly braces} -\usage{ -wrap_if_else_while_for_fun_multi_line_in_curly(pd, indent_by = 2L) -} -\arguments{ -\item{pd}{A parse table.} - -\item{indent_by}{The amount of spaces used to indent an expression in curly -braces. Used for unindention.} -} -\description{ -Wrap statements in curly braces if it is not already wrapped in a such. -} -\keyword{internal} diff --git a/man/wrap_multiline_curly.Rd b/man/wrap_multiline_curly.Rd deleted file mode 100644 index b5fc872..0000000 --- a/man/wrap_multiline_curly.Rd +++ /dev/null @@ -1,22 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rules-tokens.R -\name{wrap_multiline_curly} -\alias{wrap_multiline_curly} -\title{Wrap a multi-line statement in curly braces} -\usage{ -wrap_multiline_curly(pd, indent_by, key_token, space_after = 1L) -} -\arguments{ -\item{pd}{A parse table.} - -\item{indent_by}{The amount of spaces used to indent an expression in curly -braces. Used for unindention.} - -\item{key_token}{The token that comes right before the token that contains -the expression to be wrapped (ignoring comments). For if and while loops, -this is the closing "')'", for a for-loop it's "forcond".} -} -\description{ -Wrap a multi-line statement in curly braces -} -\keyword{internal} diff --git a/man/wrap_subexpr_in_curly.Rd b/man/wrap_subexpr_in_curly.Rd deleted file mode 100644 index c87420c..0000000 --- a/man/wrap_subexpr_in_curly.Rd +++ /dev/null @@ -1,16 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rules-tokens.R -\name{wrap_subexpr_in_curly} -\alias{wrap_subexpr_in_curly} -\title{Wrap a sub-expression in curly braces} -\usage{ -wrap_subexpr_in_curly(pd, ind_to_be_wrapped, indent_by, space_after) -} -\arguments{ -\item{ind_to_be_wrapped}{The indices of the rows that should be wrapped -into a new expression.} -} -\description{ -Wraps some rows of a parse table into a sub-expression. -} -\keyword{internal}