Skip to content

Commit 74c0951

Browse files
Merge pull request #965 from IndrajeetPatil/963_change_defaults
Default to styling all supported file formats
2 parents e63eab4 + f89eb2a commit 74c0951

File tree

7 files changed

+19
-11
lines changed

7 files changed

+19
-11
lines changed

API

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ 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)
1313
specify_transformers_drop(spaces = NULL, indention = NULL, line_breaks = NULL, tokens = NULL)
14-
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")
14+
style_dir(path = ".", ..., style = tidyverse_style, transformers = style(...), filetype = c("R", "Rprofile", "Rmd", "Rmarkdown", "Rnw", "Qmd"), 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")
16-
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")
16+
style_pkg(pkg = ".", ..., style = tidyverse_style, transformers = style(...), filetype = c("R", "Rprofile", "Rmd", "Rmarkdown", "Rnw", "Qmd"), exclude_files = "R/RcppExports.R", exclude_dirs = c("packrat", "renv"), include_roxygen_examples = TRUE, base_indention = 0, dry = "off")
1717
style_text(text, ..., style = tidyverse_style, transformers = style(...), include_roxygen_examples = TRUE, base_indention = 0)
1818
tidyverse_math_token_spacing()
1919
tidyverse_reindention()

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ editor_options:
66

77
# styler 1.7.0.9000 (Development version)
88

9+
**User-facing changes**
10+
11+
- `style_dir()` and `style_pkg()` now default to styling all supported file
12+
formats (`.R`, `.Rmd`, `.Rmarkdown`, `.Rnw`, and `.qmd`) in the (package)
13+
directory (\@IndrajeetPatil, #965).
14+
915
**Features**
1016

1117
- `filetype` `.qmd` is now supported, but not turned on by default (#931).

R/ui-styling.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ style_pkg <- function(pkg = ".",
7575
...,
7676
style = tidyverse_style,
7777
transformers = style(...),
78-
filetype = c("R", "Rprofile"),
78+
filetype = c("R", "Rprofile", "Rmd", "Rmarkdown", "Rnw", "Qmd"),
7979
exclude_files = "R/RcppExports.R",
8080
exclude_dirs = c("packrat", "renv"),
8181
include_roxygen_examples = TRUE,
@@ -255,7 +255,7 @@ style_dir <- function(path = ".",
255255
...,
256256
style = tidyverse_style,
257257
transformers = style(...),
258-
filetype = c("R", "Rprofile"),
258+
filetype = c("R", "Rprofile", "Rmd", "Rmarkdown", "Rnw", "Qmd"),
259259
recursive = TRUE,
260260
exclude_files = NULL,
261261
exclude_dirs = c("packrat", "renv"),

inst/WORDLIST

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ prefill
148148
prettycode
149149
PRs
150150
purrr
151+
qmd
151152
questionr
153+
Qmd
152154
rcmdcheck
153155
RcppExports
154156
rds

man/style_dir.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/style_pkg.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-public_api.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,17 +295,17 @@ test_that("styler can style R and Rmd files via style_pkg()", {
295295
expect_false(any(grepl("RcppExports.R", msg, fixed = TRUE)))
296296
})
297297

298-
test_that("style_pkg() does not style qmd files by default", {
298+
test_that("style_pkg() styles qmd files by default", {
299299
msg <- capture_output(
300300
style_pkg(testthat_file("public-api", "xyzpackage-qmd"))
301301
)
302302
expect_true(any(grepl("hello-world.R", msg, fixed = TRUE)))
303303
expect_true(any(grepl("test-package-xyz.R", msg, fixed = TRUE)))
304-
expect_false(any(grepl("random.Rmd", msg, fixed = TRUE)))
305-
expect_false(any(grepl("random.Rmarkdown", msg, fixed = TRUE)))
306-
expect_false(any(grepl("README.Rmd", msg, fixed = TRUE)))
304+
expect_true(any(grepl("random.Rmd", msg, fixed = TRUE)))
305+
expect_true(any(grepl("random.Rmarkdown", msg, fixed = TRUE)))
306+
expect_true(any(grepl("README.Rmd", msg, fixed = TRUE)))
307307
expect_false(any(grepl("RcppExports.R", msg, fixed = TRUE)))
308-
expect_false(any(grepl("new.qmd", msg, fixed = TRUE)))
308+
expect_true(any(grepl("new.qmd", msg, fixed = TRUE)))
309309
})
310310

311311
test_that("style_pkg() can find qmd anywhere", {

0 commit comments

Comments
 (0)