Skip to content

Commit f4f297e

Browse files
committed
Minor fixes
Fix typo in assert_tokens Add code backticks in documentation Rename prettify_local Use vector of paths Strict readme regex
1 parent 2a95508 commit f4f297e

File tree

5 files changed

+18
-30
lines changed

5 files changed

+18
-30
lines changed

R/set-assert-args.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ assert_tokens <- function(tokens) {
6565
stop(
6666
"Token(s) ", paste0(invalid_tokens, collapse = ", "), " are invalid. ",
6767
"You can lookup all valid tokens and their text ",
68-
"with styler:::looup_tokens(). Make sure you supply the values of ",
68+
"with styler:::lookup_tokens(). Make sure you supply the values of ",
6969
"the column 'token', not 'text'."
7070
)
7171
}

R/ui.R

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ NULL
1919
#' conveniently constructed via the `style` argument and `...`. See
2020
#' 'Examples'.
2121
#' @param filetype Vector of file extensions indicating which filetypes should
22-
#' be styled. Case is ignored, and the `.` is optional, e.g. c(".R", ".Rmd")
23-
#' or c("r", "rmd").
22+
#' be styled. Case is ignored, and the `.` is optional, e.g. `c(".R", ".Rmd")`
23+
#' or `c("r", "rmd")`.
2424
#' @param exclude_files Character vector with paths to files that should be
2525
#' excluded from styling.
2626
#' @section Warning:
@@ -44,44 +44,32 @@ style_pkg <- function(pkg = ".",
4444
exclude_files = "R/RcppExports.R") {
4545
pkg_root <- rprojroot::find_package_root_file(path = pkg)
4646
changed <- withr::with_dir(pkg_root,
47-
prettify_local(transformers, filetype, exclude_files)
47+
prettify_pkg(transformers, filetype, exclude_files)
4848
)
4949
invisible(changed)
5050
}
5151

52-
prettify_local <- function(transformers, filetype, exclude_files) {
52+
prettify_pkg <- function(transformers, filetype, exclude_files) {
5353

5454
filetype <- set_and_assert_arg_filetype(filetype)
55-
r_files <- test_files <- data_raw_files <- vignette_files <- readme <- NULL
55+
r_files <- vignette_files <- readme <- NULL
5656

5757
if ("\\.r" %in% filetype) {
5858
r_files <- dir(
59-
path = "R", pattern = "\\.r$", ignore.case = TRUE,
60-
recursive = TRUE, full.names = TRUE
61-
)
62-
test_files <- dir(
63-
path = "tests", pattern = "\\.r$", ignore.case = TRUE,
64-
recursive = TRUE, full.names = TRUE
65-
)
66-
data_raw_files <- dir(
67-
path = "data-raw", pattern = "\\.r$", ignore.case = TRUE,
68-
recursive = TRUE, full.names = TRUE
59+
path = c("R", "tests", "data-raw"), pattern = "\\.r$",
60+
ignore.case = TRUE, recursive = TRUE, full.names = TRUE
6961
)
7062
}
7163

7264
if ("\\.rmd" %in% filetype) {
7365
vignette_files <- dir(
74-
path = "vignettes", pattern = "\\.rmd$", ignore.case = TRUE,
75-
recursive = TRUE, full.names = TRUE
66+
path = "vignettes", pattern = "\\.rmd$",
67+
ignore.case = TRUE, recursive = TRUE, full.names = TRUE
7668
)
77-
readme <- dir(pattern = "readme\\.rmd", ignore.case = TRUE)
69+
readme <- dir(pattern = "^readme\\.rmd$", ignore.case = TRUE)
7870
}
7971

80-
files <- setdiff(
81-
c(r_files, test_files, data_raw_files, vignette_files, readme),
82-
exclude_files
83-
)
84-
72+
files <- setdiff(c(r_files, vignette_files, readme), exclude_files)
8573
transform_files(files, transformers)
8674
}
8775

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/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)