diff --git a/API b/API index 725e716d4..80b09fbe1 100644 --- a/API +++ b/API @@ -6,11 +6,11 @@ cache_activate(cache_name = NULL, verbose = TRUE) cache_clear(cache_name = NULL, ask = TRUE) cache_deactivate(verbose = TRUE) cache_info(cache_name = NULL, format = "both") -create_style_guide(initialize = default_style_guide_attributes, line_break = NULL, space = NULL, token = NULL, indention = NULL, use_raw_indention = FALSE, reindention = tidyverse_reindention(), style_guide_name = NULL, style_guide_version = NULL, more_specs_style_guide = NULL, transformers_drop = specify_transformer_dropping()) +create_style_guide(initialize = default_style_guide_attributes, line_break = NULL, space = NULL, token = NULL, indention = NULL, use_raw_indention = FALSE, reindention = tidyverse_reindention(), style_guide_name = NULL, style_guide_version = NULL, more_specs_style_guide = NULL, transformers_drop = specify_transformers_drop()) default_style_guide_attributes(pd_flat) specify_math_token_spacing(zero = "'^'", one = c("'+'", "'-'", "'*'", "'/'")) specify_reindention(regex_pattern = NULL, indention = 0, comments_only = TRUE) -specify_transformer_dropping(spaces = NULL, indention = NULL, line_breaks = NULL, tokens = NULL) +specify_transformers_drop(spaces = NULL, indention = NULL, line_breaks = NULL, tokens = NULL) style_dir(path = ".", ..., style = tidyverse_style, transformers = style(...), filetype = c("R", "Rprofile"), recursive = TRUE, exclude_files = NULL, exclude_dirs = c("packrat", "renv"), include_roxygen_examples = TRUE, base_indention = 0, dry = "off") style_file(path, ..., style = tidyverse_style, transformers = style(...), include_roxygen_examples = TRUE, base_indention = 0, dry = "off") style_pkg(pkg = ".", ..., style = tidyverse_style, transformers = style(...), filetype = c("R", "Rprofile"), exclude_files = "R/RcppExports.R", exclude_dirs = c("packrat", "renv"), include_roxygen_examples = TRUE, base_indention = 0, dry = "off") diff --git a/NAMESPACE b/NAMESPACE index a21dae794..7ab16f529 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -9,7 +9,7 @@ export(create_style_guide) export(default_style_guide_attributes) export(specify_math_token_spacing) export(specify_reindention) -export(specify_transformer_dropping) +export(specify_transformers_drop) export(style_dir) export(style_file) export(style_pkg) diff --git a/R/style-guides.R b/R/style-guides.R index b3cee64f7..a43abacb5 100644 --- a/R/style-guides.R +++ b/R/style-guides.R @@ -173,7 +173,7 @@ tidyverse_style <- function(scope = "tokens", ) } - transformers_drop <- specify_transformer_dropping( + transformers_drop <- specify_transformers_drop( spaces = list( # remove_space_before_closing_paren = c("')'", "']'"), # remove_space_before_opening_paren = c("'('", "'['", "LBB"), @@ -286,7 +286,7 @@ tidyverse_style <- function(scope = "tokens", #' @param transformers_drop A list specifying under which conditions #' transformer functions can be dropped since they have no effect on the #' code to format, most easily constructed with -#' [specify_transformer_dropping()]. This is argument experimental and may +#' [specify_transformers_drop()]. This is argument experimental and may #' change in future releases without prior notification. It was mainly #' introduced to improve speed. Listing transformers here that occur almost #' always in code does not make sense because the process of excluding them @@ -318,7 +318,7 @@ create_style_guide <- function(initialize = default_style_guide_attributes, style_guide_name = NULL, style_guide_version = NULL, more_specs_style_guide = NULL, - transformers_drop = specify_transformer_dropping()) { + transformers_drop = specify_transformers_drop()) { list( # transformer functions initialize = list(initialize = initialize), @@ -342,7 +342,7 @@ create_style_guide <- function(initialize = default_style_guide_attributes, #' `{styler}` can remove transformer functions safely removed from the list of #' transformers to be applied on every *nest* with [transformers_drop()] if the #' tokens that trigger a manipulation of the parse data are absent in the text -#' to style. `specify_transformer_dropping()` helps you specify these +#' to style. `specify_transformers_drop()` helps you specify these #' conditions. #' #' Note that the negative formulation (must be absent in order to be dropped) @@ -363,10 +363,10 @@ create_style_guide <- function(initialize = default_style_guide_attributes, #' circumstances the transformer does not have an impact on styling and can #' therefore be safely removed without affecting the styling outcome. #' -#' You can use the unexported function [test_transformers_dropping()] for some +#' You can use the unexported function [test_transformers_drop()] for some #' checks. #' @examples -#' dropping <- specify_transformer_dropping( +#' dropping <- specify_transformers_drop( #' spaces = c(remove_space_after_excl = "'!'") #' ) #' style_guide <- create_style_guide( @@ -391,10 +391,10 @@ create_style_guide <- function(initialize = default_style_guide_attributes, #' # not, not via `is.null()` and we can use the `is.null()` check to see if #' # this scope was initially required by the user. #' @export -specify_transformer_dropping <- function(spaces = NULL, - indention = NULL, - line_breaks = NULL, - tokens = NULL) { +specify_transformers_drop <- function(spaces = NULL, + indention = NULL, + line_breaks = NULL, + tokens = NULL) { list( space = spaces, indention = indention, line_break = line_breaks, token = tokens diff --git a/R/testing.R b/R/testing.R index 3d6d79a3d..9ef3a09ba 100644 --- a/R/testing.R +++ b/R/testing.R @@ -342,11 +342,11 @@ cache_more_specs_default <- function() { cache_more_specs(include_roxygen_examples = TRUE, base_indention = 0) } -#' Check if the transformers_dropping in [create_style_guide()] is consistent +#' Check if the transformers_drop in [create_style_guide()] is consistent #' with the transformers specified. #' @param transformers The output of [create_style_guide()] we want to test. #' @keywords internal -test_transformers_dropping <- function(transformers) { +test_transformers_drop <- function(transformers) { scopes <- intersect( names(transformers$transformers_drop), names(transformers) @@ -357,7 +357,7 @@ test_transformers_dropping <- function(transformers) { diff <- setdiff(names(x), names(y)) if (length(diff) > 0) { rlang::abort(paste( - "transformer_dropping specifies exclusion rules for transformers that ", + "transformers_drop specifies exclusion rules for transformers that ", "are not in the style guilde. Please add the rule to the style guide ", "or remove the dropping rules:", paste(diff, collapse = ", ") )) diff --git a/R/transform-files.R b/R/transform-files.R index 4b1b73184..cccae05ec 100644 --- a/R/transform-files.R +++ b/R/transform-files.R @@ -261,7 +261,7 @@ parse_transform_serialize_r <- function(text, #' line). #' @param transformers the transformers. #' @keywords internal -#' @seealso specify_transformer_dropping +#' @seealso specify_transformers_drop transformers_drop <- function(text, transformers) { is_colon <- text == ";" if (any(is_colon)) { diff --git a/man/create_style_guide.Rd b/man/create_style_guide.Rd index 256345a71..ef1e8add1 100644 --- a/man/create_style_guide.Rd +++ b/man/create_style_guide.Rd @@ -15,7 +15,7 @@ create_style_guide( style_guide_name = NULL, style_guide_version = NULL, more_specs_style_guide = NULL, - transformers_drop = specify_transformer_dropping() + transformers_drop = specify_transformers_drop() ) } \arguments{ @@ -60,7 +60,7 @@ beforehand in \code{purrr::partial()}.} \item{transformers_drop}{A list specifying under which conditions transformer functions can be dropped since they have no effect on the code to format, most easily constructed with -\code{\link[=specify_transformer_dropping]{specify_transformer_dropping()}}. This is argument experimental and may +\code{\link[=specify_transformers_drop]{specify_transformers_drop()}}. This is argument experimental and may change in future releases without prior notification. It was mainly introduced to improve speed. Listing transformers here that occur almost always in code does not make sense because the process of excluding them diff --git a/man/specify_transformer_dropping.Rd b/man/specify_transformers_drop.Rd similarity index 90% rename from man/specify_transformer_dropping.Rd rename to man/specify_transformers_drop.Rd index faa5a690a..e8b33732a 100644 --- a/man/specify_transformer_dropping.Rd +++ b/man/specify_transformers_drop.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/style-guides.R -\name{specify_transformer_dropping} -\alias{specify_transformer_dropping} +\name{specify_transformers_drop} +\alias{specify_transformers_drop} \title{Specify which tokens must be absent for a transformer to be dropped} \usage{ -specify_transformer_dropping( +specify_transformers_drop( spaces = NULL, indention = NULL, line_breaks = NULL, @@ -20,7 +20,7 @@ unnamed vector with tokens that match the rule. See 'Examples'.} \code{{styler}} can remove transformer functions safely removed from the list of transformers to be applied on every \emph{nest} with \code{\link[=transformers_drop]{transformers_drop()}} if the tokens that trigger a manipulation of the parse data are absent in the text -to style. \code{specify_transformer_dropping()} helps you specify these +to style. \code{specify_transformers_drop()} helps you specify these conditions. } \details{ @@ -42,12 +42,12 @@ circumstances the transformer does not have an impact on styling and can therefore be safely removed without affecting the styling outcome. } -You can use the unexported function \code{\link[=test_transformers_dropping]{test_transformers_dropping()}} for some +You can use the unexported function \code{\link[=test_transformers_drop]{test_transformers_drop()}} for some checks. } \examples{ -dropping <- specify_transformer_dropping( +dropping <- specify_transformers_drop( spaces = c(remove_space_after_excl = "'!'") ) style_guide <- create_style_guide( diff --git a/man/test_transformers_drop.Rd b/man/test_transformers_drop.Rd new file mode 100644 index 000000000..14dc9606e --- /dev/null +++ b/man/test_transformers_drop.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/testing.R +\name{test_transformers_drop} +\alias{test_transformers_drop} +\title{Check if the transformers_drop in \code{\link[=create_style_guide]{create_style_guide()}} is consistent +with the transformers specified.} +\usage{ +test_transformers_drop(transformers) +} +\arguments{ +\item{transformers}{The output of \code{\link[=create_style_guide]{create_style_guide()}} we want to test.} +} +\description{ +Check if the transformers_drop in \code{\link[=create_style_guide]{create_style_guide()}} is consistent +with the transformers specified. +} +\keyword{internal} diff --git a/man/test_transformers_dropping.Rd b/man/test_transformers_dropping.Rd deleted file mode 100644 index ff2a9f5fd..000000000 --- a/man/test_transformers_dropping.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/testing.R -\name{test_transformers_dropping} -\alias{test_transformers_dropping} -\title{Check if the transformers_dropping in \code{\link[=create_style_guide]{create_style_guide()}} is consistent -with the transformers specified.} -\usage{ -test_transformers_dropping(transformers) -} -\arguments{ -\item{transformers}{The output of \code{\link[=create_style_guide]{create_style_guide()}} we want to test.} -} -\description{ -Check if the transformers_dropping in \code{\link[=create_style_guide]{create_style_guide()}} is consistent -with the transformers specified. -} -\keyword{internal} diff --git a/man/transformers_drop.Rd b/man/transformers_drop.Rd index 8cd267b65..19623db73 100644 --- a/man/transformers_drop.Rd +++ b/man/transformers_drop.Rd @@ -20,6 +20,6 @@ expect ";" to be in it, so we don't need to apply \code{resolve_semicolon()} on every \emph{nest}. } \seealso{ -specify_transformer_dropping +specify_transformers_drop } \keyword{internal} diff --git a/tests/testthat/test-serialize_tests.R b/tests/testthat/test-serialize_tests.R index 5d5843beb..77433ee1d 100644 --- a/tests/testthat/test-serialize_tests.R +++ b/tests/testthat/test-serialize_tests.R @@ -33,19 +33,19 @@ test_that('detects non-matching style guides', { a1 = function(...) NULL, b1 = function(... ) 1 ), - transformers_drop = specify_transformer_dropping( + transformers_drop = specify_transformers_drop( spaces = c(a1 = "'+'") ) ) - expect_silent(test_transformers_dropping(sg)) + expect_silent(test_transformers_drop(sg)) sg <- create_style_guide( space = list( a1 = function(...) NULL ), - transformers_drop = specify_transformer_dropping( + transformers_drop = specify_transformers_drop( spaces = c(a2 = "'+'") ) ) - expect_error(test_transformers_dropping(sg)) + expect_error(test_transformers_drop(sg)) }) diff --git a/tests/testthat/test-transformers-drop.R b/tests/testthat/test-transformers-drop.R index fd91a220e..a93aa4921 100644 --- a/tests/testthat/test-transformers-drop.R +++ b/tests/testthat/test-transformers-drop.R @@ -9,7 +9,7 @@ remove_space_after_excl_ <- function(pd_flat) { t <- create_style_guide( space = lst(remove_space_after_excl_), - transformers_drop = specify_transformer_dropping( + transformers_drop = specify_transformers_drop( spaces = list(remove_space_after_excl_ = c("'!'")) ), style_guide_name = "styler::t@https://github.com/r-lib", @@ -50,7 +50,7 @@ test_that("transformers are removed if they are unused", { test_that("tidyverse transformers are correctly named", { # test that all dropping rules match an actual rule in the style guide expect_silent( - test_transformers_dropping(tidyverse_style()) + test_transformers_drop(tidyverse_style()) ) })