Non-invasive pretty printing of R code
This release was requested by the CRAN team since parser error messages changed, which were hard-coded in some unit tests (#1180).
Minor changes
CI
Testing
We thank everyone who helped making this release possible: @AshesITR, @averissimo, @IndrajeetPatil, @lorenzwalthert, @mcanouil, @moodymudskipper, @olivroy, @sbanville-delfi, @sorhawell, @ssh352, @swo, and @vertesy.
This release was requested by the CRAN team to fix CRAN warning on invalid numeric version inputs (#1143).
Minor changes
We thank everyone who helped making this release possible.
@krlmlr, @lorenzwalthert, @MichaelChirico, @olivroy, @rkrug, and @rossdrucker.
This release was requested by CRAN due to accidentally populating a user cache while building vignettes for R >= 4.3.0.
tempdir()
to get temporary directory instead of own unreliable heuristic (#1126).Thanks to everyone who contributed to this release: @olivroy and @krlmlr.
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:
rlang::with_handlers()
(#1103).repeat
(#1113).test-public_api.R
for better sharding (#1109).actions/checkout
to version 3 in GitHub Actions (#1098).Thanks for everyone contributing to this release:
@IndrajeetPatil, @krlmlr, @kyleam, @MichaelChirico, @mvanaman, @olivroy, and @vvarik.
Bug fixes
{{
and comments that can yield invalid code (#1070).Other
"qmd"
as a valid filetype
(#1091).Thanks for everyone who contributed to this release:
Features
indent_by
two spaces.# old style: remains compliant and won't be re-styled
my_fun <- function(long_argument = 2,
indent_up_to_first = "x") {
# ...
}
# new style: now also compliant and won't be re-styled
my_fun <- function(
long_argument = 2,
indent_double = "x") {
# ...
}
You can also use the R package {codegrip} to toggle between the two modes (#1083).
Bug fixes
{{
and comments now yields parsable output (#1088).Other user-facing changes
styler.cache_root
is not set (#1063).Infrastructure
Internals
purrr::when()
with if
statements (#1066).@examplesIf
for conditionally running examples (#1071).A big shout out to anyone who contributed to this release:
@balthasars, @hadley, @IndrajeetPatil, @juliangrimm225 and @krlmlr.
Features
Other
...
in withr::local_options()
was introduced only in v.2.3.0 (#1051).set_linebreak_after_ggplot2_plus()
to set_line_break_after_ggplot2_plus()
for consistency (@Polkas, #1049).rlang::%||%
(#1041).This release was requested by CRAN to resolve an R CMD Check note (#1044). A big hand to everyone who made this release possible:
@DaveJarvis, @IndrajeetPatil, @lorenzwalthert, @MichaelChirico, @Polkas and @Robinlovelace.
{styler} 1.8.0 comes with a host of new features like support for quarto documents, around 40% speed improvement, bug fixes and the removal of 8 recursive dependencies. We also welcome @IndrajeetPatil as a new contributor to {styler}, who has contributed significantly to this and and previous releases.
style_dir()
and style_pkg()
now default to styling all supported file formats (.R
, .Rmd
, .Rmarkdown
, .Rnw
, and .qmd
) in the (package) directory (#965, #931, #1033).style_pkg()
now excludes the auto-generated R/cpp11.R
file (#977).styler.ignore_alignment
controls if alignment should be detected (and preserved) or not (#932).alignment is detected in tibble::tribble()
(and similar) calls with more than 3 columns when left aligned (#945).
fix alignment detection for one column, mixed named/unnamed (#1035).
if there are only empty lines in a code chunk, they are all removed (#936).
apply rules for [
to [[
and its closing counterpair (#1030)
there is now at most one line break after {
and before #
(#952, #1022).
line breaks may be added to function calls to ensure indention symmetry for round braces (#975).
the cache is also invalidated on changing the stylerignore markers (#932).
{
is not put on a new line after =
and in function() {
for some edge cases (#939).
while ({})
statements are now handled the same way as function statements with regards to breaking lines (#967).
parsing of {roxygen2} example comments now also works for edge cases when there is no literal code immediately following after the end of the example section (#940).
files with no tokens in it are now transformed into zero-byte files (#962).
git checkout v1.0.0
.styler.colored_print.vertical
in vignettes so ANSI output of {prettycode} not messing with {pkgdown} (#956, #957).unlist()
(#998).nrow
arg in new_tibble()
calls (#1003).if()
+ else()
instead of ifelse()
(#1006).styler_df()
signature (#1009).odd()
and even()
were removed (#989).In total, 8 recursive dependencies are removed: {ellipsis}, {pillar}, {rematch2}, {tibble}, {utf8}, {fansi}, {lifecycle}, {pkgconfig}.
3.5
(#986).A big hand to everyone who made this release possible:
@behrman, @EngineerDanny, @gavinsimpson, @IndrajeetPatil, @jabenninghoff, @krlmlr, @lorenzwalthert, @MichaelChirico, @moodymudskipper, @RaymondBalise, @Robinlovelace, @sebffischer, @sgorm123, @stefanoborini, @wdkrnls.
new R option styler.cache_root
(defaulting to "styler"
) that determines the sub-directory under the {R.cache} cache directory that {styler} uses. Non-default caches won't be cleaned up by {styler}. We suggest "styler-perm"
(also used by {precommit}).
stylerignore markers are now interpreted as regular expressions instead of comments that must match exactly. This allows to specify multiple markers in one regular expression for styler.ignore_start
and styler.ignore_stop
, e.g. to use markers for lintr and styler on the same line, you can use options(styler.ignore_start = "nolint start|styler: off"
:
# nolint start, styler: off
1 +1
# nolint end
# styler: on
As a consequence of this approach, the defaults for styler.ignore_start
and styler.ignore_stop
omit the #
(#849).
usethis::use_github_action("style")
(#914).filetype
in Example for style_dir()
(#855).substitute(x %>% y)
don't get ()
added anymore for one level deep (not more yet, see #889), as this can change outcome of the code (#876)..onLoad()
method no longer broken with {cli} >= 3.1 (#893).+
should no longer give any error on styling when there are comments and line breaks under certain circumstances (#905).c("x" = 2)
) are now correctly detected (#881).~
causes now indention, like +
, -
, |
etc. (#902).Warning: Unknown or uninitialised column:
was fixed (#885).EQ_SUB
(=
), the corresponding key is moved to that line too (#923).indenty_by
is now also respected when curly braces are added to an if statement by {styler} (#915).OutDec
is set to a non-default value (#912).*-in_tree
files in .Rbuildignore
(#879).v2
._
(#929).Thanks to all contributors that made this release possible:
@bersbersbers, @daniel-wrench, @dbykova, @EngrStudent, @hadley, @IndrajeetPatil, @jam1015, @jooyoungseo, @kalaschnik, @kaytif, @kpagacz, @krlmlr, @lionel-, @lorenzwalthert, @maelle, @MichaelChirico, @mine-cetinkaya-rundel, @neuwirthe, @Polkas, @pwang2, @sebffischer, @ShixiangWang, @ssh352, and @xjtusjtu.