Repository navigation
Update style_dir() - #292
Conversation
a2d9294 to
cdc110e
Compare
Codecov Report
@@ Coverage Diff @@
## master #292 +/- ##
==========================================
- Coverage 92.01% 91.83% -0.19%
==========================================
Files 29 30 +1
Lines 1302 1322 +20
==========================================
+ Hits 1198 1214 +16
- Misses 104 108 +4
Continue to review full report at Codecov.
|
| ..., | ||
| style = tidyverse_style, | ||
| transformers = style(...), | ||
| filetype = "R", |
There was a problem hiding this comment.
can we change that to c("r") also?
There was a problem hiding this comment.
Sorry did the other merge from my phone and I thought you'd changed it already. Happy to change this too.
There was a problem hiding this comment.
@krlmlr do you prefer to stick with "R" everywhere instead of "r"? Its kind of a philosophical debate I guess...
There was a problem hiding this comment.
Can we use "R" everywhere? It doesn't seem to affect the code, but the default file extension is .R and not .r, and we should be consistent here.
There was a problem hiding this comment.
I agree that the default here and elsewhere should be uppercase. I think @lorenzwalthert wanted to emphasize that this argument can be/is a vector so wanted to use c("R") instead. I think the case inconsistency was incidental/accidental.
There was a problem hiding this comment.
I thought c("R") was an artifact... I feel it's enough if we just mention that the argument also accepts vectors in the documentation.
| ..., | ||
| style = tidyverse_style, | ||
| transformers = style(...), | ||
| filetype = c("r"), |
There was a problem hiding this comment.
I don't see how this argument does affect the function call, i.e. it is not really used further downstream if I see that correctly.
There was a problem hiding this comment.
So was your intend to wait with merging anyways until #293 is resolved?
There was a problem hiding this comment.
Yeah this was just because the other functions (style_dir & prettify_any) were already inheriting params from here (for documentation) and I figured we'd be adding this to style_pkg later anyway.
There was a problem hiding this comment.
Ok, lets wait with merging then.
…capsulate/re-organise with helper functions plus extend tests
6f46f8f to
6d620fb
Compare
|
Ok, this should be ready for further review now. |
| #' conveniently constructed via the `style` argument and `...`. See | ||
| #' 'Examples'. | ||
| #' @param filetype Vector of file extensions indicating which filetypes should | ||
| #' be styled. Case is ignored, and the `.` is optional, e.g. c(".R", ".Rmd") |
| stop( | ||
| "Token(s) ", paste0(invalid_tokens, collapse = ", "), " are invalid. ", | ||
| "You can lookup all valid tokens and their text ", | ||
| "with styler:::looup_tokens(). Make sure you supply the values of ", |
| path = "vignettes", pattern = "\\.rmd$", ignore.case = TRUE, | ||
| recursive = TRUE, full.names = TRUE | ||
| ) | ||
| readme <- dir(pattern = "readme\\.rmd", ignore.case = TRUE) |
| r_files <- test_files <- data_raw_files <- vignette_files <- readme <- NULL | ||
|
|
||
| if ("\\.r" %in% filetype) { | ||
| r_files <- dir( |
There was a problem hiding this comment.
The paths argument to dir() seems to be vectorized, not sure about older versions of R.
There was a problem hiding this comment.
Thanks - I had overlooked this. Based on this source code from 2000, I think it's safe to assume that the paths argument has been vectorized since pre R 2.0 days, so I'll go ahead and combine these.
| r_files <- dir( | ||
| path = "R", pattern = "[.][rR]$", recursive = TRUE, full.names = TRUE | ||
| ) | ||
| prettify_local <- function(transformers, filetype, exclude_files) { |
There was a problem hiding this comment.
I'm not sure the function name still matches the intent.
| --- | ||
|
|
||
| ```{r setup, include=FALSE} | ||
| 1+1 |
There was a problem hiding this comment.
Do the tests actually test that styling is applied?
There was a problem hiding this comment.
I think we just check whether the file was named in the message about changed files. Should we test for the actual change?
There was a problem hiding this comment.
They don't check whether styling is applied, just which files are being named in the changed files message. @lorenzwalthert suggested these tests so I kinda assumed we had our bases covered with actual styling tests elsewhere.
|
Thanks very much for the review @krlmlr! Unfortunately I won't be able to get back to this until this evening (i.e. outside office hours). I hope I'm not holding up your CRAN release? |
|
No, that's totally fine. |
|
Thanks for working on this! |
Fix typo in assert_tokens Add code backticks in documentation Rename prettify_local Use vector of paths Strict readme regex
|
Hi @krlmlr! Sorry I should have requested a follow up review from you on Wednesday eve after pushing some changes. I think I have addressed all your comments. The drop in testing coverage is very marginal - but in any case highlights the question of whether or not you feel there is sufficient testing? (please refer to the comments above) |
|
Thanks again! |
- Remove `regex_none()`, document `NULL` default. - `style_dir()` and `style_pkg()` now also handle `.Rmd` files (#292, @jonmcalder). - Add test for styling `.Rmd` files. - Better error message for styling new files via the RStudio addin (#295). - Spelling via devtools::spell_check() (#294). - Roundtrip and CLI (#289).
|
Happy to help out - another good learning opportunity for me. Thanks @krlmlr! |
Extension to
style_dir()to address the first part of #291