Skip to content

Commit 3337939

Browse files
Merge pull request #711 from lorenzwalthert/subset-transformers
- Remove unused transformers before processing (#711).
2 parents 8bb1e81 + 4e8a248 commit 3337939

16 files changed

+555
-80
lines changed

.Rbuildignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
^API$
66
^README\.Rmd$
77
^README-.*\.png$
8-
^.travis.yml
98
^appveyor\.yml$
109
^tic\.R$
11-
^\.travis\.yml$
1210
^docs$
1311
^_pkgdown\.yml$
1412
CONTRIBUTING.md
@@ -20,5 +18,5 @@ revdep
2018
^\.pre-commit-config\.yaml$
2119
^brew\-log$
2220
^\.github/$
23-
^touchstone/$
24-
^.github/$
21+
^touchstone$
22+
^\.github$

API

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +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)
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_transformers_drop(spaces = NULL, indention = NULL, line_breaks = NULL, tokens = NULL)
1314
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")
1415
style_file(path, ..., style = tidyverse_style, transformers = style(...), include_roxygen_examples = TRUE, base_indention = 0, dry = "off")
1516
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +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_transformers_drop)
1213
export(style_dir)
1314
export(style_file)
1415
export(style_pkg)

NEWS.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
style tokens, you had to always also style spaces, indention, line breaks as
2222
well (#705, #707).
2323

24+
- New argument `transformers_drop` in `create_style_guide()` to be populated with
25+
new helper function `specify_transformers_drop()` for specifying conditions
26+
under which transformers are not going to be used and can therefore be
27+
omitted without effecting the result of styling (#711).
28+
2429
## Major changes
2530

2631

@@ -31,9 +36,10 @@
3136
or focus loss, so this feature becomes less relevant. (#631).
3237
- blank lines in function calls and headers are now removed, for the former only
3338
when there are no comments before or after the blank line (#629, #630, #635).
34-
- speed improvements: (~10%) when cache is activated because transformers are not
35-
captured as character anymore (#679), ~ 3% in low-level optimization (#691).
36-
Require magrittr 2.0 gives about 7% speed improvement (#681).
39+
- speed improvements: ~10% when cache is activated because transformers are not
40+
captured as character anymore (#679), ~3% in low-level optimization (#691).
41+
7% by requiring magrittr 2.0 (#681), ~8% by dropping unused transformers
42+
(#711) .
3743
- `#<<` is now recognized as the xaringan marker and no space is added after`#`
3844
(#700).
3945

R/rules-spaces.R

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -185,20 +185,6 @@ set_space_in_curly_curly <- function(pd) {
185185
pd
186186
}
187187

188-
add_space_before_brace <- function(pd_flat) {
189-
# TODO remove this, it has no effect since { can only appear in the first
190-
# position of the nest and taking lead(op_after, default = FALSE) will always
191-
# yield a vector of FALSE only.
192-
op_after <- pd_flat$token %in% "'{'"
193-
if (!any(op_after)) {
194-
return(pd_flat)
195-
}
196-
op_before <- lead(op_after, default = FALSE)
197-
idx_before <- op_before & (pd_flat$newlines == 0L) & pd_flat$token != "'('"
198-
pd_flat$spaces[idx_before] <- pmax(pd_flat$spaces[idx_before], 1L)
199-
pd_flat
200-
}
201-
202188
add_space_after_comma <- function(pd_flat) {
203189
comma_after <- (pd_flat$token == "','") & (pd_flat$newlines == 0L)
204190
pd_flat$spaces[comma_after] <- pmax(pd_flat$spaces[comma_after], 1L)

0 commit comments

Comments
 (0)