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

Consider styler to replace formatR #201

Closed
wlandau opened this issue Jan 30, 2018 · 7 comments
Closed

Consider styler to replace formatR #201

wlandau opened this issue Jan 30, 2018 · 7 comments

Comments

@wlandau
Copy link
Member

wlandau commented Jan 30, 2018

For projects running drake > 5.0.0, it may be time to switch from formatR::tidy_source() to styler::style_text():

transformer <- tidyverse_style(
  scope = "tokens",
  strict = TRUE,
  indent_by = 2,
  start_comments_with_one_space = FALSE,
  reindention = tidyverse_reindention(),
  math_token_spacing = tidyverse_math_token_spacing()
)
style_text(text = command, transformers = transformer)

To do:

  1. Strip comments from text.
  2. Build in back compatibility of projects originally build with drake <= 5.0.0.
@wlandau
Copy link
Member Author

wlandau commented Jan 30, 2018

See yihui/formatR#76. If formatR will continue to be supported, the large effort and risk of transitioning to styler may not be worth it.

@wlandau
Copy link
Member Author

wlandau commented Feb 1, 2018

Given yihui/formatR#76, I am not likely to actually make this change until much later in the future.

@wlandau wlandau closed this as completed Feb 1, 2018
@lorenzwalthert
Copy link
Contributor

Hi. I just saw this and I wanted to point out to one problem with formatR that styler can dhandle better: tidyeval Syntax. Because formatR converts !!! x to !(!(!x)) or similar, so in the case you actually want to execute code, that may be detrimental. If you just use it for caching, I guess it's ok.

@wlandau
Copy link
Member Author

wlandau commented Feb 1, 2018

Thanks, !! was actually the reason I started looking into styler. But I did manage to work around that shortcoming in #200: the styled/standardized version of the command is no longer the version that also needs to run. That takes the pressure off of formatR/styler. I am still sometimes having problems with '!(!...))', but not in a way that either tool was designed to help.

@lorenzwalthert
Copy link
Contributor

lorenzwalthert commented Feb 1, 2018

Ok fine 😊. So probably it's a good decision to stick with formaR, at least as long as styler is a young and maturing project (e.g. there are more than 20 issues labeled with "Status: Postponed" that should be resolved at some point).

@wlandau
Copy link
Member Author

wlandau commented Feb 5, 2018

I will definitely revisit the question. I believe styler has a bright future and that making the switch will eventually be the right decision.

@wlandau
Copy link
Member Author

wlandau commented Oct 28, 2018

Replacing with #562 instead. I would prefer base R if possible because this is such a sensitive piec of the internals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants