Skip to content

Commit

Permalink
Merge pull request #1124 from r-lib/rc-1.10.1
Browse files Browse the repository at this point in the history
Release {styler} v1.10.1
  • Loading branch information
lorenzwalthert authored Jun 5, 2023
2 parents d71e2cc + b1d4793 commit 8f839e6
Show file tree
Hide file tree
Showing 15 changed files with 70 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .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: f3498c421d68a1db26de1a1fe3ecc91dd6f03b5e
hooks:
- id: style-files
args:
Expand Down
2 changes: 1 addition & 1 deletion 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.10.0.9000
Version: 1.10.1
Authors@R:
c(person(given = "Kirill",
family = "Müller",
Expand Down
10 changes: 9 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<!-- NEWS.md is maintained by https://cynkra.github.io/fledge, do not edit -->
# 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
Expand Down
2 changes: 1 addition & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ remove_old_cache_files <- function() {
path_version_specific,
full.names = TRUE, recursive = TRUE
)
date_boundary <- Sys.time() - 60L * 60L * 24L * 6L
date_boundary <- Sys.time() - as.difftime(6L, units = "days")
file.remove(
all_cached[file.info(all_cached)$mtime < date_boundary]
)
Expand Down
4 changes: 2 additions & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ editor_options:
wrap: 79
---

This is a release requested by the CRAN team to delete empty directories in the
user's cache.
This is a release requested by the CRAN team to delete the population of the
user's cache while building vignettes.


## Test environments
Expand Down
1 change: 1 addition & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ iNZightTools
io
ixmypi
ized
JamesIves
Jupyterlab
Kirill
kirill
Expand Down
23 changes: 23 additions & 0 deletions tests/testthat/test-cache-clean-up.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
test_that("styler tests did not use R.cache in user root", {
skip_on_cran()
skip_on_covr()
skip_during_parallel()
expect_true(
length(list.files(R.cache::getCachePath("styler"), recursive = TRUE)) == 0L
)
})

test_that("clear Cache", {
# if R CMD CHECK is detected, R.cache root is set to a temp
# directory by default.
# https://github.com/HenrikBengtsson/R.cache/commit/c7ac171f15f035674346d5504049c38cf07c268f
# Hence, this clean up won't clean up the user directory.
skip_during_parallel()
cache_path <- R.cache::getCachePath("styler")
R.cache::clearCache(cache_path, recursive = TRUE, prompt = FALSE)
skip_on_cran()
skip_on_covr()
expect_true(
length(list.dirs(R.cache::getCachePath("styler"))) == 1L
)
})
18 changes: 0 additions & 18 deletions tests/testthat/test-zzz.R
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
test_that("styler tests did not use R.cache in user root", {
skip_on_cran()
skip_on_covr()
expect_true(
length(list.files(R.cache::getCachePath("styler"), recursive = TRUE)) == 0L
)
})

test_that("clear Cache", {
R.cache::clearCache(R.cache::getCachePath("styler"), recursive = TRUE)
skip_on_cran()
skip_on_covr()
expect_true(
length(list.dirs(R.cache::getCachePath("styler"))) == 1L
)
})


test_that("can delete empty cache directory", {
skip_if(getRversion() < package_version("4.0.0"))
skip_on_cran()
Expand Down
2 changes: 2 additions & 0 deletions vignettes/caching.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
options(styler.colored_print.vertical = FALSE)
styler::cache_deactivate()
```

```{r setup}
Expand Down
9 changes: 9 additions & 0 deletions vignettes/customizing_styler.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ vignette: >
%\VignetteEncoding{UTF-8}
---

```{r}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
options(styler.colored_print.vertical = FALSE)
styler::cache_deactivate()
```

This vignette provides a high-level overview of how styler works and how you can define your own style guide and format code according to it. If you simply want to customize the tidyverse style guide to your needs, check out `vignette("styler")`, to remove some rules, have a look at `vignette("remove_rules")`. How to distribute a custom style guide is described in `vignette("distribute_custom_style_guides")`.

# How styler works
Expand Down
7 changes: 6 additions & 1 deletion vignettes/detect-alignment.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ vignette: >
---

```{r, include=FALSE}
knitr::opts_chunk$set(eval = FALSE)
knitr::opts_chunk$set(
eval = FALSE,
collapse = TRUE,
comment = "#>"
)
styler::cache_deactivate()
```

# Overview
Expand Down
2 changes: 2 additions & 0 deletions vignettes/distribute_custom_style_guides.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
styler::cache_deactivate()
options(styler.colored_print.vertical = FALSE)
```

This vignette describes how you can distribute your own style guide. It builds on `vignette("customizing_styler")` and assumes you understand how to create a style guide with `create_style_guide()`.
Expand Down
5 changes: 4 additions & 1 deletion vignettes/remove_rules.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
styler::cache_deactivate()
```

```{r, echo = FALSE, include = FALSE}
Expand Down Expand Up @@ -60,7 +61,9 @@ Here are the steps required to deactivate a rule you don't like
Lets assume you want to remove the rule that turns `=` into `<-` for
assignment. That means you want

string = "hi there"
```
string = "hi there"
```

to remain unchanged after applying styler. This is not the case if you use the
default style guide of styler:
Expand Down
2 changes: 2 additions & 0 deletions vignettes/strict.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ knitr::opts_chunk$set(
results = "hide"
)
styler::cache_deactivate()
knitr::knit_engines$set(list(
styler = function(options) {
options$comment <- ""
Expand Down
9 changes: 7 additions & 2 deletions vignettes/styler.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ knitr::knit_engines$set(list(
))
options(styler.colored_print.vertical = FALSE)
styler::cache_deactivate()
```

# Entry-points
Expand All @@ -35,14 +36,18 @@ styler provides the following API to format code:

- RStudio Addins for styling the active file, styling the current package and styling the highlighted selection, see `help("styler_addins")`.

Beyond that, styler can be used through other tools documented in the `vignette("third-party-integrations")`.
Beyond that, styler can be used through other tools documented in the `vignette("third-party-integrations")`. Let's get started.
```{r}
library(styler)
```



### Passing arguments to the style guide

styler separates the abstract definition of a style guide from the application of it. That's why you must supply a style guide via `transformers` when styling (in case you don't want to rely on the defaults):

```{r}
library(styler)
style_text("a + b", transformers = tidyverse_style(scope = "indention"))
```

Expand Down

0 comments on commit 8f839e6

Please sign in to comment.