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

Cranrel #8

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
37 changes: 17 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,25 @@
# Default configuration for use with tic package
# Usually you shouldn't need to change the first part of the file

# DO NOT CHANGE THE CODE BELOW
before_install: R -q -e 'install.packages(c("remotes", "curl", "knitr", "rmarkdown")); remotes::install_github("ropenscilabs/tic"); tic::prepare_all_stages(); remotes::install_deps(dependencies = TRUE); tic::before_install()'
install: R -q -e 'tic::install()'
after_install: R -q -e 'tic::after_install()'
before_script: R -q -e 'tic::before_script()'
script: R -q -e 'tic::script()'
after_success: R -q -e 'tic::after_success()'
after_failure: R -q -e 'tic::after_failure()'
before_deploy: R -q -e 'tic::before_deploy()'
deploy:
provider: script
script: R -q -e 'tic::deploy()'
on:
all_branches: true
after_deploy: R -q -e 'tic::after_deploy()'
after_script: R -q -e 'tic::after_script()'
# DO NOT CHANGE THE CODE ABOVE

# Custom parts:

# Header
language: r
#matrix: 3x Linux, 1x OS X
matrix:
include:
- r: 3.1
- r: 3.2
- r: 3.3
- r: 3.4
- r: release
env:
- BUILD_PKGDOWN: true
- r: devel

- os: osx
osx_image: xcode7.3
r: release
latex: false

sudo: false
dist: trusty
latex: false
Expand Down
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ URL: https://github.com/r-lib/styler
BugReports: https://github.com/r-lib/styler/issues
Imports:
backports (>= 1.1.0),
cli,
cli (>= 1.0.0),
magrittr (>= 1.0.1),
purrr (>= 0.2.3),
rematch2,
rematch2 (>= 2.0.1),
rlang (>= 0.1.1),
rprojroot (>= 1.1),
tibble (>= 1.4.2),
tools,
withr,
xfun
withr (>= 1.0.0),
xfun (>= 0.1)
Suggests:
data.tree (>= 0.1.6),
dplyr,
Expand Down
131 changes: 122 additions & 9 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,93 @@
# styler 1.1.1

This is primarily a maintenance release upon the request of the CRAN team
(#490).

## Major changes

- Users can now control style configurations for styler Addins (#463, #500),
using the `Set style` Addin. See `?styler::styler_addins` for details.

## Minor changes

- `%>%` almost always causes a line break now (#503).

- fix roxygen code example styling indention (#455) and EOF spacing (#469).

- fix indention for for loop edge case (#457) and comments in pipe chain
(#482).

- more consistent styling of multi-line strings (#459).

- fix line-break styling around comma (#479).

- fix bug that may cause an error when the variable `text` in any name space
before styler on the search path was defined and did not have length 1
(#484).

- `style_pkg()` now also styles the "demo" directory by default (#453).

- more minimal version dependencies on other packages and clean-up (9cfe808c,
7077d440, 8ee486c6).

- remove slightly confusing warning about empty strings caused with roxygen code
examples and Rmd.

- Removed right apostrophe to let package pass R CMD Check in strict Latin-1
locale (#490, reason for release).

## Adaption of styler

Since it's never been mentioned in the release notes, we also mention here where
else you can use styler functionality:

* `usethis::use_tidy_style()` styles your project according to the tidyverse
style guide.

* `reprex::reprex(style = TRUE)` to prettify reprex code before printing. To
permanently use `style = TRUE` without specifying it every time, you can add
the following line to your `.Rprofile` (via `usethis::edit_r_profile()`):
`options(reprex.styler = TRUE)`.

* you can pretty-print your R code in RMarkdown reports without having styler
modifying the source. This feature is implemented as a code chunk option in
knitr. use `tidy = "styler"` in the header of a code chunks (e.g. ` ```{r
name-of-the-chunk, tidy = "styler"}`), or `knitr::opts_chunk$set(tidy =
"styler")` at the top of your RMarkdown script.

* pretty-printing of [drake](https://github.com/ropensci/drake) workflow data
frames with `drake::drake_plan_source()`.

* Adding styler as a fixer to the [ale
Plug-in](https://github.com/w0rp/ale/pull/2401#issuecomment-485942966) for
VIM.

Thanks to all contributors involved, in particular
[@ArthurPERE](https://github.com/ArthurPERE),
[@hadley](https://github.com/hadley),
[@igordot](https://github.com/igordot),
[@IndrajeetPatil](https://github.com/IndrajeetPatil),
[@jackwasey](https://github.com/jackwasey),
[@jcrodriguez1989](https://github.com/jcrodriguez1989),
[@jennybc](https://github.com/jennybc),
[@jonmcalder](https://github.com/jonmcalder),
[@katrinleinweber](https://github.com/katrinleinweber),
[@krlmlr](https://github.com/krlmlr),
[@lorenzwalthert](https://github.com/lorenzwalthert),
[@michaelquinn32](https://github.com/michaelquinn32),
[@msberends](https://github.com/msberends),
[@raynamharris](https://github.com/raynamharris),
[@riccardoporreca](https://github.com/riccardoporreca),
[@rjake](https://github.com/rjake),
[@Robinlovelace](https://github.com/Robinlovelace),
[@skirmer](https://github.com/skirmer),
[@thalesmello](https://github.com/thalesmello),
[@tobiasgerstenberg](https://github.com/tobiasgerstenberg),
[@tvatter](https://github.com/tvatter),
[@wdearden](https://github.com/wdearden),
[@wmayner](https://github.com/wmayner), and
[@yech1990](https://github.com/yech1990).

# styler 1.1.0

This release introduces new features and is fully backward-compatible. It also
Expand All @@ -7,27 +97,36 @@ adapts to changes in the R parser committed into R devel (#419).

* styler can now style roxygen code examples in the source code of package
(#332) as well as Rnw files (#431).

* the print method for the output of `style_text()` (`print.vertical()`) now
returns syntax-highlighted code by default, controllable via the option
returns syntax-highlighted code by default, controllable via the option
`styler.colored_print.vertical` (#417).

* the README was redesigned (#413).

* semi-colon expression that contained multiple assignments was fixed (#404).

## Minor Changes

* cursor position is remembered for styling via Addin (#416).
* adapt spacing around tilde for multi-token expressions(#424) and brace
edge case (#425).

* adapt spacing around tilde for multi-token expressions(#424) and brace edge
case (#425).

* only add brackets to piped function call if RHS is a symbol (#422).
* increase coverage again to over 90% (#412).

* increase coverage again to over 90% (#412).

* move rule that turns single quotes into double quotes to token modifier in
`tidyverse_style_guide() (#406).

* remove line-breaks before commas (#405).

* removed package dependency enc in favor of xfun (#442).

Thanks to all contributors for patches, issues and the like:
@jonmcalder, @krlmlr, @IndrajeetPatil, @kalibera, @Hasnep, @kiranmaiganji,
@dirkschumacher, @ClaytonJY, @wlandau, @maurolepore
Thanks to all contributors for patches, issues and the like: @jonmcalder,
@krlmlr, @IndrajeetPatil, @kalibera, @Hasnep, @kiranmaiganji, @dirkschumacher,
@ClaytonJY, @wlandau, @maurolepore

# styler 1.0.2

Expand All @@ -36,18 +135,24 @@ This is a maintenance release without any breaking API changes.
## Major Changes

* Fixed indention for named multi-line function calls (#372).

* Non-R code chunks in `.Rmd` files are now respected and won't get styled
(#386).

## Minor Changes

* Fixing an edge case in which, if very long strings were present in the code,
tokens could be replaced with wrong text (#384).

* Spacing around tilde in formulas depends now on whether there is a LHS in the
formula (#379).

* Spaces are now also added around `EQ_SUB` (`=`) (#380).

* Added `CONTRIBUTING.md` to outline guidelines for contributing to styler.

* More informative error messages for parsing problems (#401, #400).

* Improved documentation (#387).

Thanks to all contributors for patches, issues and the like: @katrinleinweber,
Expand All @@ -62,11 +167,14 @@ This is a maintenance release without any breaking API changes.

* Removed implicit `dplyr` dependency via `purrr:::map_dfr()` (thanks
@jimhester, #324).

* Added required minimal version dependency for purr (`>= 0.2.3`) (#338).

* We rely on the tibble package which was optimized for speed in `v1.4.2` so
styler should run ~2x as fast
[(#348)](https://github.com/tidyverse/tibble/pull/348). For that reason, styler
now depends on `tibble >= 1.4.2`.
[(#348)](https://github.com/tidyverse/tibble/pull/348). For that reason,
styler now depends on `tibble >= 1.4.2`.

* In the dependency `enc`, a bug was fixed that removed/changed non-ASCII
characters. Hence, styler now depends on `enc >= 0.2` (#348).

Expand All @@ -75,12 +183,16 @@ This is a maintenance release without any breaking API changes.
* We're now recognizing and respecting more DSLs used in R comments: rplumber
(`#*`, #306), shebang `#/!` (#345), knitr chunk headers for spinning (`#+` /
`#-`, #362).

* Named arguments can stay on the first line if call is multi-line (#318).

* No space anymore with `tidyverse_style()` after `!!` since with `rlang 0.2`,
`!!` now binds tighter (#322), spacing around `~` (#316), no space anymore
around `^` (#308).

* Code chunks in Rmd documents that don't use the R engine are no longer
formatted (#313).

* Various bug fixes and edge case improvements.

Thanks to all contributors for patches, issues and the like: @devSJR, @klrmlr,
Expand Down Expand Up @@ -158,3 +270,4 @@ specify_reindention(
)
initialize_default_attributes(pd_flat)
```

3 changes: 1 addition & 2 deletions R/communicate.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Communicate a warning if necessary
#'
#' If roundtrip verification was not possible, issue a warning to review the
#' If round trip verification was not possible, issue a warning to review the
#' changes carefully.
#' @param changed Boolean with indicating for each file whether or not it has
#' been changed.
Expand Down Expand Up @@ -34,4 +34,3 @@ assert_data.tree_installation <- function() {
abort("The package data.tree needs to be installed for this functionality.")
}
}

4 changes: 2 additions & 2 deletions R/environments.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Work with parser versions
#'
#' The structure of the parse data affects many operations in styler. There was
#' unexpected behaviour of the parser that styler was initially designed to work
#' unexpected behavior of the parser that styler was initially designed to work
#' around. Examples are [#187](https://github.com/r-lib/styler/issues/187),
#' [#216](https://github.com/r-lib/styler/issues/216),
#' [#100](https://github.com/r-lib/styler/issues/100) and others. With
Expand All @@ -26,7 +26,7 @@
#' data. This does not necessarily mean that the version found is the
#' actual version, but it *behaves* like it. For example, code that does not
#' contain `EQ_ASSIGN` is parsed the same way with version 1 and 2. If the
#' behaviour is identical, the version is set to 1.
#' behavior is identical, the version is set to 1.
#' @param version The version of the parser to be used.
#' @param pd A parse table such as the output from
#' `utils::getParseData(parse(text = text))`.
Expand Down
29 changes: 21 additions & 8 deletions R/expr-is.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ NULL
#' curly brackets.
#' @keywords internal
is_curly_expr <- function(pd) {
if (is.null(pd)) return(FALSE)
if (is.null(pd)) {
return(FALSE)
}
pd$token[1] == "'{'"
}

Expand All @@ -32,22 +34,30 @@ is_while_expr <- function(pd) {
#' @describeIn pd_is Checks whether `pd` is a function call.
#' @keywords internal
is_function_call <- function(pd) {
if (is.null(pd)) return(FALSE)
if (is.na(pd$token_before[2])) return(FALSE)
if (is.null(pd)) {
return(FALSE)
}
if (is.na(pd$token_before[2])) {
return(FALSE)
}
pd$token_before[2] == "SYMBOL_FUNCTION_CALL"
}

#' @describeIn pd_is Checks whether `pd` is a function declaration.
#' @keywords internal
is_function_dec <- function(pd) {
if (is.null(pd)) return(FALSE)
if (is.null(pd)) {
return(FALSE)
}
pd$token[1] == "FUNCTION"
}

#' @describeIn pd_is Checks for every token whether or not it is a comment.
#' @keywords internal
is_comment <- function(pd) {
if (is.null(pd)) return(FALSE)
if (is.null(pd)) {
return(FALSE)
}
pd$token == "COMMENT"
}

Expand All @@ -66,7 +76,9 @@ is_comment <- function(pd) {
#' expression (like `a~b`).
#' @keywords internal
is_tilde_expr <- function(pd, tilde_pos = c(1, 2)) {
if (is.null(pd) || nrow(pd) == 1) return(FALSE)
if (is.null(pd) || nrow(pd) == 1) {
return(FALSE)
}
any(pd$token[tilde_pos] == "'~'")
}

Expand All @@ -81,7 +93,9 @@ is_symmetric_tilde_expr <- function(pd) {
}

is_subset_expr <- function(pd) {
if (is.null(pd) || nrow(pd) == 1) return(FALSE)
if (is.null(pd) || nrow(pd) == 1) {
return(FALSE)
}
pd$token[2] == "'['"
}

Expand Down Expand Up @@ -148,4 +162,3 @@ contains_else_expr_that_needs_braces <- function(pd) {
FALSE
}
}

Loading