Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default to styling all supported file formats #965

Merged
merged 8 commits into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions API
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
4 changes: 2 additions & 2 deletions R/ui-styling.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"),
Expand Down
2 changes: 2 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ prefill
prettycode
PRs
purrr
qmd
questionr
Qmd
rcmdcheck
RcppExports
rds
Expand Down
2 changes: 1 addition & 1 deletion man/style_dir.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/style_pkg.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions tests/testthat/test-public_api.R
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand Down