Skip to content

Commit e24dc68

Browse files
committed
Exclude R/import-standalone.+R files from restyling.
1 parent acd0b46 commit e24dc68

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

R/ui-styling.R

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ style_pkg <- function(pkg = ".",
6969
style = tidyverse_style,
7070
transformers = style(...),
7171
filetype = c("R", "Rprofile", "Rmd", "Rmarkdown", "Rnw", "Qmd"),
72-
exclude_files = c("R/RcppExports.R", "R/cpp11.R"),
72+
exclude_files = c("R/RcppExports.R", "R/cpp11.R", "R/import-standalone.+R"),
7373
exclude_dirs = c("packrat", "renv"),
7474
include_roxygen_examples = TRUE,
7575
base_indention = 0L,
@@ -91,8 +91,8 @@ style_pkg <- function(pkg = ".",
9191
#' ".Rmd")`, or `c("r", "rmd")`. Supported values (after standardization) are:
9292
#' "r", "rprofile", "rmd", "rmarkdown", "rnw", "qmd". Rmarkdown is treated as
9393
#' Rmd.
94-
#' @param exclude_files Character vector with paths to files that should be
95-
#' excluded from styling.
94+
#' @param exclude_files Character vector with paths or regular expressions to files
95+
#' that should be excluded from styling.
9696
#' @param exclude_dirs Character vector with directories to exclude
9797
#' (recursively). Note that the default values were set for consistency with
9898
#' [style_dir()] and as these directories are anyways not styled.
@@ -107,8 +107,10 @@ prettify_pkg <- function(transformers,
107107
dry) {
108108
filetype_ <- set_and_assert_arg_filetype(filetype)
109109
r_files <- rprofile_files <- vignette_files <- readme <- NULL
110+
exclude_files <- set_arg_paths(exclude_files)
111+
exclude_files_regex <- paste0(exclude_files[!file.exists(exclude_files)], collapse = "|")
110112
exclude_files <- c(
111-
set_arg_paths(exclude_files),
113+
exclude_files,
112114
dir_without_.(exclude_dirs, pattern = map_filetype_to_pattern(filetype))
113115
)
114116
if ("\\.r" %in% filetype_) {
@@ -171,6 +173,8 @@ prettify_pkg <- function(transformers,
171173
c(r_files, rprofile_files, vignette_files, readme),
172174
exclude_files
173175
)
176+
# Remove the regex.
177+
files <- files[!grepl(exclude_files_regex, files)]
174178
transform_files(files,
175179
transformers = transformers,
176180
include_roxygen_examples = include_roxygen_examples,

man/prettify_any.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/prettify_pkg.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/style_dir.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/style_pkg.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)