Skip to content

Commit 578c491

Browse files
consistently use transformers_drop
1 parent 45dca2a commit 578c491

12 files changed

+49
-49
lines changed

API

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ cache_activate(cache_name = NULL, verbose = TRUE)
66
cache_clear(cache_name = NULL, ask = TRUE)
77
cache_deactivate(verbose = TRUE)
88
cache_info(cache_name = NULL, format = "both")
9-
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())
9+
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())
1010
default_style_guide_attributes(pd_flat)
1111
specify_math_token_spacing(zero = "'^'", one = c("'+'", "'-'", "'*'", "'/'"))
1212
specify_reindention(regex_pattern = NULL, indention = 0, comments_only = TRUE)
13-
specify_transformer_dropping(spaces = NULL, indention = NULL, line_breaks = NULL, tokens = NULL)
13+
specify_transformers_drop(spaces = NULL, indention = NULL, line_breaks = NULL, tokens = NULL)
1414
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")
1515
style_file(path, ..., style = tidyverse_style, transformers = style(...), include_roxygen_examples = TRUE, base_indention = 0, dry = "off")
1616
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")

NAMESPACE

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export(create_style_guide)
99
export(default_style_guide_attributes)
1010
export(specify_math_token_spacing)
1111
export(specify_reindention)
12-
export(specify_transformer_dropping)
12+
export(specify_transformers_drop)
1313
export(style_dir)
1414
export(style_file)
1515
export(style_pkg)

R/style-guides.R

+10-10
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ tidyverse_style <- function(scope = "tokens",
173173
)
174174
}
175175

176-
transformers_drop <- specify_transformer_dropping(
176+
transformers_drop <- specify_transformers_drop(
177177
spaces = list(
178178
# remove_space_before_closing_paren = c("')'", "']'"),
179179
# remove_space_before_opening_paren = c("'('", "'['", "LBB"),
@@ -286,7 +286,7 @@ tidyverse_style <- function(scope = "tokens",
286286
#' @param transformers_drop A list specifying under which conditions
287287
#' transformer functions can be dropped since they have no effect on the
288288
#' code to format, most easily constructed with
289-
#' [specify_transformer_dropping()]. This is argument experimental and may
289+
#' [specify_transformers_drop()]. This is argument experimental and may
290290
#' change in future releases without prior notification. It was mainly
291291
#' introduced to improve speed. Listing transformers here that occur almost
292292
#' 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,
318318
style_guide_name = NULL,
319319
style_guide_version = NULL,
320320
more_specs_style_guide = NULL,
321-
transformers_drop = specify_transformer_dropping()) {
321+
transformers_drop = specify_transformers_drop()) {
322322
list(
323323
# transformer functions
324324
initialize = list(initialize = initialize),
@@ -342,7 +342,7 @@ create_style_guide <- function(initialize = default_style_guide_attributes,
342342
#' `{styler}` can remove transformer functions safely removed from the list of
343343
#' transformers to be applied on every *nest* with [transformers_drop()] if the
344344
#' tokens that trigger a manipulation of the parse data are absent in the text
345-
#' to style. `specify_transformer_dropping()` helps you specify these
345+
#' to style. `specify_transformers_drop()` helps you specify these
346346
#' conditions.
347347
#'
348348
#' 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,
363363
#' circumstances the transformer does not have an impact on styling and can
364364
#' therefore be safely removed without affecting the styling outcome.
365365
#'
366-
#' You can use the unexported function [test_transformers_dropping()] for some
366+
#' You can use the unexported function [test_transformers_drop()] for some
367367
#' checks.
368368
#' @examples
369-
#' dropping <- specify_transformer_dropping(
369+
#' dropping <- specify_transformers_drop(
370370
#' spaces = c(remove_space_after_excl = "'!'")
371371
#' )
372372
#' style_guide <- create_style_guide(
@@ -391,10 +391,10 @@ create_style_guide <- function(initialize = default_style_guide_attributes,
391391
#' # not, not via `is.null()` and we can use the `is.null()` check to see if
392392
#' # this scope was initially required by the user.
393393
#' @export
394-
specify_transformer_dropping <- function(spaces = NULL,
395-
indention = NULL,
396-
line_breaks = NULL,
397-
tokens = NULL) {
394+
specify_transformers_drop <- function(spaces = NULL,
395+
indention = NULL,
396+
line_breaks = NULL,
397+
tokens = NULL) {
398398
list(
399399
space = spaces, indention = indention, line_break = line_breaks,
400400
token = tokens

R/testing.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,11 @@ cache_more_specs_default <- function() {
342342
cache_more_specs(include_roxygen_examples = TRUE, base_indention = 0)
343343
}
344344

345-
#' Check if the transformers_dropping in [create_style_guide()] is consistent
345+
#' Check if the transformers_drop in [create_style_guide()] is consistent
346346
#' with the transformers specified.
347347
#' @param transformers The output of [create_style_guide()] we want to test.
348348
#' @keywords internal
349-
test_transformers_dropping <- function(transformers) {
349+
test_transformers_drop <- function(transformers) {
350350
scopes <- intersect(
351351
names(transformers$transformers_drop),
352352
names(transformers)
@@ -357,7 +357,7 @@ test_transformers_dropping <- function(transformers) {
357357
diff <- setdiff(names(x), names(y))
358358
if (length(diff) > 0) {
359359
rlang::abort(paste(
360-
"transformer_dropping specifies exclusion rules for transformers that ",
360+
"transformers_drop specifies exclusion rules for transformers that ",
361361
"are not in the style guilde. Please add the rule to the style guide ",
362362
"or remove the dropping rules:", paste(diff, collapse = ", ")
363363
))

R/transform-files.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ parse_transform_serialize_r <- function(text,
261261
#' line).
262262
#' @param transformers the transformers.
263263
#' @keywords internal
264-
#' @seealso specify_transformer_dropping
264+
#' @seealso specify_transformers_drop
265265
transformers_drop <- function(text, transformers) {
266266
is_colon <- text == ";"
267267
if (any(is_colon)) {

man/create_style_guide.Rd

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/specify_transformer_dropping.Rd renamed to man/specify_transformers_drop.Rd

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/test_transformers_drop.Rd

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/test_transformers_dropping.Rd

-17
This file was deleted.

man/transformers_drop.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-serialize_tests.R

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,19 @@ test_that('detects non-matching style guides', {
3333
a1 = function(...) NULL,
3434
b1 = function(... ) 1
3535
),
36-
transformers_drop = specify_transformer_dropping(
36+
transformers_drop = specify_transformers_drop(
3737
spaces = c(a1 = "'+'")
3838
)
3939
)
40-
expect_silent(test_transformers_dropping(sg))
40+
expect_silent(test_transformers_drop(sg))
4141

4242
sg <- create_style_guide(
4343
space = list(
4444
a1 = function(...) NULL
4545
),
46-
transformers_drop = specify_transformer_dropping(
46+
transformers_drop = specify_transformers_drop(
4747
spaces = c(a2 = "'+'")
4848
)
4949
)
50-
expect_error(test_transformers_dropping(sg))
50+
expect_error(test_transformers_drop(sg))
5151
})

tests/testthat/test-transformers-drop.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ remove_space_after_excl_ <- function(pd_flat) {
99

1010
t <- create_style_guide(
1111
space = lst(remove_space_after_excl_),
12-
transformers_drop = specify_transformer_dropping(
12+
transformers_drop = specify_transformers_drop(
1313
spaces = list(remove_space_after_excl_ = c("'!'"))
1414
),
1515
style_guide_name = "styler::t@https://github.com/r-lib",
@@ -50,7 +50,7 @@ test_that("transformers are removed if they are unused", {
5050
test_that("tidyverse transformers are correctly named", {
5151
# test that all dropping rules match an actual rule in the style guide
5252
expect_silent(
53-
test_transformers_dropping(tidyverse_style())
53+
test_transformers_drop(tidyverse_style())
5454
)
5555
})
5656

0 commit comments

Comments
 (0)