Skip to content

Commit

Permalink
Merge branch 'main' into split-roxygen-exec
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil authored Dec 3, 2023
2 parents 1288ccc + edf399c commit a1589a4
Show file tree
Hide file tree
Showing 87 changed files with 327 additions and 218 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-all-examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/check-full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -56,6 +56,7 @@ jobs:
- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
error-on: '"note"'
error-on: 'ifelse(getRversion() > "3.6", "warning", "note")'
env:
_R_CHECK_FORCE_SUGGESTS_: false
_R_CHECK_STOP_ON_INVALID_NUMERIC_VERSION_INPUTS_: true
2 changes: 1 addition & 1 deletion .github/workflows/check-link-rot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -39,7 +39,7 @@ jobs:

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4.4.1
uses: JamesIves/github-pages-deploy-action@v4.4.3
with:
clean: false
branch: gh-pages
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
)
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.11.0
uses: styfle/cancel-workflow-action@0.12.0
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install system dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/touchstone-receive.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
config: ${{ steps.read_touchstone_config.outputs.config }}
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ default_language_version:

repos:
- repo: https://github.com/lorenzwalthert/precommit
rev: v0.3.2.9007
rev: v0.3.2.9019
hooks:
- id: style-files
args:
Expand Down Expand Up @@ -34,8 +34,9 @@ repos:
- id: roxygenize
additional_dependencies:
- r-lib/pkgapi
- dplyr@1.0.9
- roxygen2@7.2.2
- dplyr@1.1.2
- roxygen2@7.2.3
- rlang@1.1.0
- id: use-tidy-description
- id: spell-check
exclude: >
Expand Down
2 changes: 1 addition & 1 deletion API
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ specify_reindention(regex_pattern = NULL, indention = 0L, 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", "Rmd", "Rmarkdown", "Rnw", "Qmd"), recursive = TRUE, exclude_files = NULL, exclude_dirs = c("packrat", "renv"), include_roxygen_examples = TRUE, base_indention = 0L, dry = "off")
style_file(path, ..., style = tidyverse_style, transformers = style(...), include_roxygen_examples = TRUE, base_indention = 0L, dry = "off")
style_pkg(pkg = ".", ..., style = tidyverse_style, transformers = style(...), filetype = c("R", "Rprofile", "Rmd", "Rmarkdown", "Rnw", "Qmd"), exclude_files = c("R/RcppExports.R", "R/cpp11.R"), exclude_dirs = c("packrat", "renv"), include_roxygen_examples = TRUE, base_indention = 0L, dry = "off")
style_pkg(pkg = ".", ..., style = tidyverse_style, transformers = style(...), filetype = c("R", "Rprofile", "Rmd", "Rmarkdown", "Rnw", "Qmd"), exclude_files = c("R/RcppExports\\.R", "R/cpp11\\.R", "R/import-standalone.*\\.R"), exclude_dirs = c("packrat", "renv"), include_roxygen_examples = TRUE, base_indention = 0L, dry = "off")
style_text(text, ..., style = tidyverse_style, transformers = style(...), include_roxygen_examples = TRUE, base_indention = 0L)
tidyverse_math_token_spacing()
tidyverse_reindention()
Expand Down
3 changes: 1 addition & 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.9.1
Version: 1.10.2
Authors@R:
c(person(given = "Kirill",
family = "Müller",
Expand Down Expand Up @@ -37,7 +37,6 @@ Imports:
Suggests:
data.tree (>= 0.1.6),
digest,
dplyr,
here,
knitr,
prettycode,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ importFrom(purrr,pmap)
importFrom(purrr,pwalk)
importFrom(rlang,"%||%")
importFrom(rlang,abort)
importFrom(rlang,check_installed)
importFrom(rlang,is_installed)
importFrom(rlang,seq2)
importFrom(rlang,set_names)
Expand Down
53 changes: 53 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,58 @@
<!-- NEWS.md is maintained by https://cynkra.github.io/fledge, do not edit -->

# styler 1.10.2

This release was requested by the CRAN team to fix CRAN warning on invalid
numeric version inputs (#1143).

**Minor changes**

* Use cli messaging for cache (#1127).
* Use latest (and stable!) pre-commit (#1144).
* Fix CRAN warning on invalid numeric version inputs (#1143).
* Bump JamesIves/github-pages-deploy-action from 4.4.2 to 4.4.3 (#1139).
* fix pre-commit (#1132).
* Don't require dplyr anywhere (#1131).

We thank everyone who helped making this release possible.

[&#x0040;krlmlr](https://github.com/krlmlr), [&#x0040;lorenzwalthert](https://github.com/lorenzwalthert), [&#x0040;MichaelChirico](https://github.com/MichaelChirico), [&#x0040;olivroy](https://github.com/olivroy), [&#x0040;rkrug](https://github.com/rkrug), and [&#x0040;rossdrucker](https://github.com/rossdrucker).

# styler 1.10.1

This release was requested by CRAN due to accidentally populating a user cache while building vignettes for R >= 4.3.0.

* Code quality improvements (#1122).
* Bump JamesIves/github-pages-deploy-action from 4.4.1 to 4.4.2 (#1123).

Thanks to everyone who contributed to this release: [&#x0040;olivroy](https://github.com/olivroy) and [&#x0040;krlmlr](https://github.com/krlmlr).

# styler 1.10.0

This release contains speed-ups between 20% and 40% depending on your use case
thanks to replacing {base} functionality with {vctrs} (#1114). With the speed
boost introduced in version 1.8.0 in Oct. 2022, {styler} is now up to 2x as fast
as before release 1.8.0.

This release was created upon a request by the CRAN team to actively manage not
just cached files but also the potentially empty cache directories they live in
(#1118). Here are the changes in detail:


- Require at least R 3.6 (#1101).
- Prefer {vctrs} functions over slower {base} equivalents (#1114).
- Replace deprecated use of `rlang::with_handlers()` (#1103).
- Remove tail recursion in favor of `repeat` (#1113).
- split `test-public_api.R` for better sharding (#1109).
- 0-pad filenames for sharding (#1110)
- add missing {testthat} snapshots (#1115).
- Bump {touchstone} config (#1104, #1107).
- Bump `actions/checkout` to version 3 in GitHub Actions (#1098).

Thanks for everyone contributing to this release:

[&#x0040;IndrajeetPatil](https://github.com/IndrajeetPatil), [&#x0040;krlmlr](https://github.com/krlmlr), [&#x0040;kyleam](https://github.com/kyleam), [&#x0040;MichaelChirico](https://github.com/MichaelChirico), [&#x0040;mvanaman](https://github.com/mvanaman), [&#x0040;olivroy](https://github.com/olivroy), and [&#x0040;vvarik](https://github.com/vvarik).

# styler 1.9.1

**Bug fixes**
Expand Down
7 changes: 0 additions & 7 deletions R/communicate.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,3 @@ communicate_summary <- function(changed, ruler_width) {
cli::cat_rule(width = max(40L, ruler_width))
}
}


assert_data.tree_installation <- function() {
if (!is_installed("data.tree")) {
abort("The package data.tree needs to be installed for this functionality.")
}
}
2 changes: 1 addition & 1 deletion R/nest.R
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ nest_parse_data <- function(pd_flat) {

rhs <- nest_(child, "child", setdiff(names(child), "parent_"))

nested <- left_join(internal, rhs, by = c("id" = "parent_"))
nested <- left_join(internal, rhs, by = c(id = "parent_"))

children <- nested$child
for (i in seq_along(children)) {
Expand Down
2 changes: 1 addition & 1 deletion R/nested-to-tree.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ create_tree_from_pd_with_default_style_attributes <- function(pd,
#' }
#' @keywords internal
create_node_from_nested_root <- function(pd_nested, structure_only) {
assert_data.tree_installation()
check_installed("data.tree")
name <- if (structure_only) {
"Hierarchical structure"
} else {
Expand Down
6 changes: 2 additions & 4 deletions R/parse.R
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,8 @@ ensure_correct_txt <- function(pd, text) {

if (!lines_and_cols_match(new_text)) {
abort(paste(
"Error in styler:::ensure_correct_txt().",
"Please file an issue on GitHub (https://github.com/r-lib/styler/issues)"
))
"Error in styler:::ensure_correct_txt()."
), .internal = TRUE)
}
names_to_keep <- setdiff(
names(new_text),
Expand All @@ -183,7 +182,6 @@ ensure_correct_txt <- function(pd, text) {
#' changes from "all strings" to "all problematic strings", is partly
#' misleading and this approach was chosen for performance reasons only.
#' @param pd A parse table.
#' @param text The initial code to style.
#' @keywords internal
is_insufficiently_parsed_string <- function(pd) {
grepl("^\\[", pd$text) & pd$token == "STR_CONST"
Expand Down
2 changes: 1 addition & 1 deletion R/rules-indention.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ indent_braces <- function(pd, indent_by) {
#' @keywords internal
unindent_fun_dec <- function(pd, indent_by = 2L) {
if (is_function_declaration(pd)) {
idx_closing_brace <- which(pd$token %in% "')'")
idx_closing_brace <- which(pd$token == "')'")
fun_dec_head <- seq2(2L, idx_closing_brace)
if (is_double_indent_function_declaration(pd, indent_by = indent_by)) {
pd$indent[fun_dec_head] <- 2L * indent_by
Expand Down
23 changes: 11 additions & 12 deletions R/rules-line-breaks.R
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ style_line_break_around_curly <- function(strict, pd) {
closing_before <- pd$token == "'}'"
opening_before <- (pd$token == "'{'")
to_break <- lag(opening_before, default = FALSE) | closing_before
len_to_break <- sum(to_break)
pd$lag_newlines[to_break] <- ifelse(
pd$token[to_break] == "COMMENT",
pmin(1L, pd$lag_newlines[to_break]),
Expand Down Expand Up @@ -268,21 +267,20 @@ set_line_break_after_assignment <- function(pd) {

#' Set line break for multi-line function calls
#' @param pd A parse table.
#' @param except_token_after A character vector with tokens after "'('" that do
#' not cause a line break after "'('".
#' @param except_text_before A character vector with text before "'('" that do
#' not cause a line break after "'('".
#' @param except_token_before A character vector with text before "')'" that do
#' not cause a line break before "')'".
#' @param force_text_before A character vector with text before "'('" that
#' forces a line break after every argument in the call.
#' @param except_token_before A character vector with tokens that do
#' not cause a line break after them.
#' @name set_line_break_if_call_is_multi_line
#'
#' @keywords internal
NULL

#' Sets line break after opening parenthesis
#'
#' @param pd The parse table.
#' @param except_token_after The tokens after the token that cause an exception.
#' @param except_text_before A character vector with text before a token that
#' does not cause a line break.
#' @param force_text_before A character vector with text before "'('" that
#' forces a line break after every argument in the call.
#' @details
#' In general, every call that is multi-line has a line break after the opening
#' parenthesis. Exceptions:
Expand Down Expand Up @@ -341,7 +339,7 @@ set_line_break_after_opening_if_call_is_multi_line <- function(pd,
#' position of the first named argument and breaks returns the index of it.
#' If there is no named argument, the line is broken right after the opening
#' parenthesis.
#' @inheritParams set_line_break_if_call_is_multi_line
#' @param pd A parse table.
#' @keywords internal
find_line_break_position_in_multiline_call <- function(pd) {
candidate <- (which(pd$token == "EQ_SUB") - 1L)[1L]
Expand Down Expand Up @@ -377,7 +375,8 @@ set_line_break_before_closing_call <- function(pd, except_token_before) {
}


#' @rdname set_line_break_if_call_is_multi_line
#' @describeIn set_line_break_if_call_is_multi_line Remove line breaks in
#' function calls.
#' @keywords internal
remove_line_break_in_fun_call <- function(pd, strict) {
if (is_function_call(pd)) {
Expand Down
14 changes: 7 additions & 7 deletions R/set-assert-args.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set_arg_write_tree <- function(write_tree) {
if (is.na(write_tree)) {
write_tree <- is_installed("data.tree")
} else if (write_tree) {
assert_data.tree_installation()
check_installed("data.tree")
}
write_tree
}
Expand All @@ -21,29 +21,29 @@ set_arg_write_tree <- function(write_tree) {
#' @inheritParams make_transformer
#' @keywords internal
assert_transformers <- function(transformers) {
version_cutoff <- 2.0
version_cutoff <- "2.0"
no_name <- is.null(transformers$style_guide_name)
no_version <- is.null(transformers$style_guide_version)
if (no_name || no_version) {
action <- if (utils::packageVersion("styler") >= version_cutoff) {
"are not supported anymore"
} else {
"depreciated and will be removed in a future version of styler."
"deprecated and will be removed in a future version of styler."
}
message <- paste(
"Style guides without a name and a version field are",
action, "\nIf you are a user: Open an issue on",
"https://github.com/r-lib/styler and provide a reproducible example",
"of this error. \nIf you are a developer:",
"When you create a style guide with `styler::create_style_guide()`, the",
"When you create a style guide with {.fn styler::create_style_guide}, the",
"argument `style_guide_name` and `style_guide_version` should be",
"non-NULL. See help(\"create_style_guide\") for how to set them."
"non-NULL. See {.help styler::create_style_guide} for how to set them."
)

if (utils::packageVersion("styler") >= version_cutoff) {
rlang::abort(message)
cli::cli_abort(message)
} else {
rlang::warn(message)
cli::cli_warn(message)
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions R/styler-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
#' @importFrom magrittr "%>%"
#' @importFrom purrr compact partial flatten flatten_int flatten_chr
#' @importFrom purrr map map_lgl map_int map_chr map2 map2_chr map_at pmap pwalk
#' @importFrom rlang abort warn seq2 is_installed "%||%" set_names
#' @importFrom vctrs vec_rbind
#' @importFrom vctrs vec_slice
#' @importFrom vctrs vec_split
#' @importFrom rlang abort warn seq2 check_installed is_installed "%||%" set_names
#' @importFrom vctrs vec_rbind vec_slice vec_split
## usethis namespace: end
NULL

Expand Down
4 changes: 2 additions & 2 deletions R/stylerignore.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ add_stylerignore <- function(pd_flat) {
pd_flat$indicator_off <- cumsum_start + cumsum_stop
is_invalid <- cumsum_start - cumsum_stop < 0L | cumsum_start - cumsum_stop > 1L
if (any(is_invalid)) {
warn(paste0(
cli::cli_warn(paste0(
"Invalid stylerignore sequences found, potentially ignoring some of the ",
"markers set.\nSee `help(\"stylerignore\", \"styler\")`."
"markers set.\nSee {.help styler::stylerignore}."
))
}

Expand Down
4 changes: 2 additions & 2 deletions R/testing.R
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ local_test_setup <- function(cache = FALSE,
.local_envir = parent.frame()) {
current_cache <- cache_info(format = "tabular")
withr::local_options(
list("styler.quiet" = TRUE, "R.cache.rootPath" = tempfile()),
list(styler.quiet = TRUE, R.cache.rootPath = tempfile()),
.local_envir = .local_envir
)
if (cache) {
Expand Down Expand Up @@ -379,5 +379,5 @@ skip_during_parallel <- function() {
Sys.getenv("STYLER_TEST_IS_TRULY_PARALLEL", TRUE) %>%
toupper() %>%
as.logical() %>%
testthat::skip_if()
testthat::skip_if("Running in parallel")
}
Loading

0 comments on commit a1589a4

Please sign in to comment.