Skip to content
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: 3 additions & 1 deletion .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ jobs:
- uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Setup system dependencies
run: |
sudo apt install cmake libcurl4-openssl-dev libnode-dev pandoc
- name: Set up Python
uses: actions/setup-python@v6.0.0
with:
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: styler
Title: Non-Invasive Pretty Printing of R Code
Version: 1.11.0
Version: 1.11.0.9001
Authors@R:
c(person(given = "Kirill",
family = "Müller",
Expand Down Expand Up @@ -53,7 +53,6 @@ Roxygen: list(markdown = TRUE, roclets = c( "rd", "namespace", "collate",
if (rlang::is_installed("pkgapi")) "pkgapi::api_roclet" else {
warning("Please install r-lib/pkgapi to make sure the file API is kept
up to date"); NULL}))
RoxygenNote: 7.3.3
Language: en-US
Config/testthat/edition: 3
Config/testthat/parallel: true
Expand Down Expand Up @@ -107,3 +106,4 @@ Collate:
'vertical.R'
'visit.R'
'zzz.R'
Config/roxygen2/version: 8.0.0
22 changes: 11 additions & 11 deletions R/indent.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,29 @@ indent_without_paren_if_else <- function(pd, indent_by) {
}
needs_indention_now <- pd$lag_newlines[
next_non_comment(pd, which(pd$token == "')'"))
] > 0L
] >
0L

if (needs_indention_now) {
pd$indent[expr_after_if] <- indent_by
}

else_idx <- which(pd$token == "ELSE")
if (length(else_idx) == 0L) {
els_idx <- which(pd$token == "ELSE")
if (length(els_idx) == 0L) {
return(pd)
}
expr_after_else_idx <- next_non_comment(pd, else_idx)
has_else_without_curly_or_else_chid <-
any(pd$token == "ELSE") &&
pd$child[[expr_after_else_idx]]$token[1L] != "'{'" &&
pd$child[[expr_after_else_idx]]$token[1L] != "IF"
expr_after_else_idx <- next_non_comment(pd, els_idx)
has_else_without_curly_or_else_chid <- any(pd$token == "ELSE") &&
pd$child[[expr_after_else_idx]]$token[1L] != "'{'" &&
pd$child[[expr_after_else_idx]]$token[1L] != "IF"

needs_indention_now <- pd$lag_newlines[
next_non_comment(pd, which(pd$token == "ELSE"))
] > 0L
] >
0L

if (has_else_without_curly_or_else_chid && needs_indention_now) {
pd$indent[seq(else_idx + 1L, nrow(pd))] <- indent_by
pd$indent[seq(els_idx + 1L, nrow(pd))] <- indent_by
}
pd
}
Expand Down Expand Up @@ -200,7 +201,6 @@ needs_indention_one <- function(pd,
}



#' Set the multi-line column
#'
#' Sets the column `multi_line` in `pd` by checking row-wise whether any child
Expand Down
1 change: 0 additions & 1 deletion R/initialize.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ default_style_guide_attributes <- function(pd_flat) {
}



#' Initialize attributes
#'
#' @name initialize_attributes
Expand Down
1 change: 1 addition & 0 deletions R/io.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ transform_utf8_one <- function(path, fun, dry) {
identical_content <- identical(file_with_info$text, new)
identical <- identical_content && !file_with_info$missing_EOF_line_break
if (!identical) {
# fmt: skip
switch(dry,
fail = rlang::abort(
paste0(
Expand Down
5 changes: 3 additions & 2 deletions R/style-guides.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ tidyverse_style <- function(scope = "tokens",

line_break_manipulators <- if ("line_breaks" %in% scope) {
list(
# fmt: skip
remove_empty_lines_after_opening_and_before_closing_braces =
remove_empty_lines_after_opening_and_before_closing_braces,
set_line_break_around_comma_and_or = set_line_break_around_comma_and_or,
Expand Down Expand Up @@ -159,8 +160,7 @@ tidyverse_style <- function(scope = "tokens",
set_line_break_after_opening_if_call_is_multi_line,
except_token_after = "COMMENT",
# don't modify line break here
except_text_before = c("ifelse", "if_else"),
force_text_before = "switch" # force line break after first token
except_text_before = c("ifelse", "if_else")
)
},
remove_line_break_in_fun_call = purrr::partial(
Expand Down Expand Up @@ -238,6 +238,7 @@ tidyverse_style <- function(scope = "tokens",
)

style_guide_name <- "styler::tidyverse_style@https://github.com/r-lib"
# fmt: skip
create_style_guide(
# transformer functions
initialize = default_style_guide_attributes,
Expand Down
1 change: 1 addition & 0 deletions R/testing.R
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ style_empty <- function(text, base_indention = 0L) {
#' @describeIn test_transformer Transformations for indention based on operators
#' @keywords internal
style_op <- function(text, base_indention = 0L) {
# fmt: skip
transformers <- list(
# transformer functions
initialize = default_style_guide_attributes,
Expand Down
1 change: 0 additions & 1 deletion R/token-create.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ find_start_pos_id <- function(pd,
}



#' Validate sequence of new position ids
#'
#' Ids created with `after = TRUE` can have `pos_id` values between x.0 and
Expand Down
1 change: 1 addition & 0 deletions R/token-define.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# styler: off
# fmt: skip
token <- rbind.data.frame(
c("&", "logical", "AND"),
c("&&", "logical", "AND2"),
Expand Down
1 change: 1 addition & 0 deletions R/transform-code.R
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ get_engine_pattern <- function() {
#' @inheritParams separate_chunks
#' @keywords internal
get_knitr_pattern <- function(filetype) {
# fmt: skip
switch(filetype,
Rnw = knitr::all_patterns[["rnw"]],
Rmd = knitr::all_patterns[["md"]]
Expand Down
1 change: 0 additions & 1 deletion R/transform-files.R
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@ apply_transformers <- function(pd_nested, transformers) {
}



#' Check whether a round trip verification can be carried out
#'
#' If scope was set to "line_breaks" or lower (compare [tidyverse_style()]),
Expand Down
2 changes: 1 addition & 1 deletion man/alignment_drop_last_expr.Rd

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

6 changes: 3 additions & 3 deletions man/cache_activate.Rd

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

6 changes: 3 additions & 3 deletions man/cache_clear.Rd

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

6 changes: 3 additions & 3 deletions man/cache_info.Rd

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

8 changes: 4 additions & 4 deletions man/caching.Rd

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

6 changes: 3 additions & 3 deletions man/create_pos_ids.Rd

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

6 changes: 3 additions & 3 deletions man/create_tokens.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/dir_without_..Rd

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

4 changes: 0 additions & 4 deletions man/env_current.Rd

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

4 changes: 2 additions & 2 deletions man/next_non_comment.Rd

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

6 changes: 3 additions & 3 deletions man/pd_is.Rd

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

4 changes: 2 additions & 2 deletions man/scope_normalize.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/set_line_break_before_curly_opening.Rd

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

10 changes: 5 additions & 5 deletions man/style_dir.Rd

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

8 changes: 4 additions & 4 deletions man/style_file.Rd

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

10 changes: 5 additions & 5 deletions man/style_pkg.Rd

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

8 changes: 4 additions & 4 deletions man/style_text.Rd

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

1 change: 1 addition & 0 deletions man/styler-package.Rd

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

Loading
Loading