diff --git a/API b/API index 73b353643..b497e5795 100644 --- a/API +++ b/API @@ -11,9 +11,9 @@ default_style_guide_attributes(pd_flat) specify_math_token_spacing(zero = "'^'", one = c("'+'", "'-'", "'*'", "'/'")) specify_reindention(regex_pattern = NULL, indention = 0, comments_only = TRUE) specify_transformers_drop(spaces = NULL, indention = NULL, line_breaks = NULL, tokens = NULL) -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") +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") style_file(path, ..., style = tidyverse_style, transformers = style(...), include_roxygen_examples = TRUE, base_indention = 0, dry = "off") -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") +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") style_text(text, ..., style = tidyverse_style, transformers = style(...), include_roxygen_examples = TRUE, base_indention = 0) tidyverse_math_token_spacing() tidyverse_reindention() diff --git a/NEWS.md b/NEWS.md index ce072c002..18b5d62c6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,12 @@ editor_options: # styler 1.7.0.9000 (Development version) +**User-facing changes** + +- `style_dir()` and `style_pkg()` now default to styling all supported file + formats (`.R`, `.Rmd`, `.Rmarkdown`, `.Rnw`, and `.qmd`) in the (package) + directory (\@IndrajeetPatil, #965). + **Features** - `filetype` `.qmd` is now supported, but not turned on by default (#931). diff --git a/R/ui-styling.R b/R/ui-styling.R index 7c26d2265..f77ed8d4b 100644 --- a/R/ui-styling.R +++ b/R/ui-styling.R @@ -75,7 +75,7 @@ style_pkg <- function(pkg = ".", ..., style = tidyverse_style, transformers = style(...), - filetype = c("R", "Rprofile"), + filetype = c("R", "Rprofile", "Rmd", "Rmarkdown", "Rnw", "Qmd"), exclude_files = "R/RcppExports.R", exclude_dirs = c("packrat", "renv"), include_roxygen_examples = TRUE, @@ -255,7 +255,7 @@ style_dir <- function(path = ".", ..., style = tidyverse_style, transformers = style(...), - filetype = c("R", "Rprofile"), + filetype = c("R", "Rprofile", "Rmd", "Rmarkdown", "Rnw", "Qmd"), recursive = TRUE, exclude_files = NULL, exclude_dirs = c("packrat", "renv"), diff --git a/inst/WORDLIST b/inst/WORDLIST index 92d9706b8..0fb9d4363 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -148,7 +148,9 @@ prefill prettycode PRs purrr +qmd questionr +Qmd rcmdcheck RcppExports rds diff --git a/man/style_dir.Rd b/man/style_dir.Rd index aeea28162..3208bab17 100644 --- a/man/style_dir.Rd +++ b/man/style_dir.Rd @@ -9,7 +9,7 @@ style_dir( ..., style = tidyverse_style, transformers = style(...), - filetype = c("R", "Rprofile"), + filetype = c("R", "Rprofile", "Rmd", "Rmarkdown", "Rnw", "Qmd"), recursive = TRUE, exclude_files = NULL, exclude_dirs = c("packrat", "renv"), diff --git a/man/style_pkg.Rd b/man/style_pkg.Rd index 63851bcdf..342f1fa51 100644 --- a/man/style_pkg.Rd +++ b/man/style_pkg.Rd @@ -9,7 +9,7 @@ style_pkg( ..., style = tidyverse_style, transformers = style(...), - filetype = c("R", "Rprofile"), + filetype = c("R", "Rprofile", "Rmd", "Rmarkdown", "Rnw", "Qmd"), exclude_files = "R/RcppExports.R", exclude_dirs = c("packrat", "renv"), include_roxygen_examples = TRUE, diff --git a/tests/testthat/test-public_api.R b/tests/testthat/test-public_api.R index 6c4aac1fe..bf5d31e42 100644 --- a/tests/testthat/test-public_api.R +++ b/tests/testthat/test-public_api.R @@ -295,17 +295,17 @@ test_that("styler can style R and Rmd files via style_pkg()", { expect_false(any(grepl("RcppExports.R", msg, fixed = TRUE))) }) -test_that("style_pkg() does not style qmd files by default", { +test_that("style_pkg() styles qmd files by default", { msg <- capture_output( style_pkg(testthat_file("public-api", "xyzpackage-qmd")) ) expect_true(any(grepl("hello-world.R", msg, fixed = TRUE))) expect_true(any(grepl("test-package-xyz.R", msg, fixed = TRUE))) - expect_false(any(grepl("random.Rmd", msg, fixed = TRUE))) - expect_false(any(grepl("random.Rmarkdown", msg, fixed = TRUE))) - expect_false(any(grepl("README.Rmd", msg, fixed = TRUE))) + expect_true(any(grepl("random.Rmd", msg, fixed = TRUE))) + expect_true(any(grepl("random.Rmarkdown", msg, fixed = TRUE))) + expect_true(any(grepl("README.Rmd", msg, fixed = TRUE))) expect_false(any(grepl("RcppExports.R", msg, fixed = TRUE))) - expect_false(any(grepl("new.qmd", msg, fixed = TRUE))) + expect_true(any(grepl("new.qmd", msg, fixed = TRUE))) }) test_that("style_pkg() can find qmd anywhere", {