Tags: devSJR/styler
Tags
Initial release. These are functions used to style code. They style a directory, a whole package, a file or a string. ``` style_dir(path = ".", ..., style = tidyverse_style, transformers = style(...), filetype = "R", recursive = TRUE, exclude_files = NULL ) style_pkg(pkg = ".", ..., style = tidyverse_style, transformers = style(...), filetype = "R", exclude_files = "R/RcppExports.R" ) style_file(path, ..., style = tidyverse_style, transformers = style(...) ) style_text(text, ..., style = tidyverse_style, transformers = style(...)) ``` These functions are the style guides implemented. ``` 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() ) tidyverse_reindention() tidyverse_math_token_spacing()) ``` This function is used to create a style guide. ``` createindention = NULL, use_raw_indention = FALSE,
- Remove `regex_none()`, document `NULL` default. - `style_dir()` and `style_pkg()` now also handle `.Rmd` files (r-lib#292, @jonmcalder). - Add test for styling `.Rmd` files. - Better error message for styling new files via the RStudio addin (r-lib#295). - Spelling via devtools::spell_check() (r-lib#294). - Roundtrip and CLI (r-lib#289).
- Adapt documentation (r-lib#290). - Add roundtrip (r-lib#287). - Fix AppVeyor builds. - Fix token insertion / comment interaction (r-lib#279). - Clarify labelling strategy (r-lib#285). - Fixing and extending Rstudioaddins (r-lib#283). - Fix eq assign parsing (r-lib#276). - style_files -> vectorized style_file (r-lib#273). - Refactoring (r-lib#270). - Fix CI (r-lib#275). - Fix covr (r-lib#274). - Renaming files (r-lib#271). - Handle styling of an unsaved active file (r-lib#243). - Test R 3.1 and R 3.2 (r-lib#249). - Allow empty {} without line break (r-lib#261). - Wrap expr in expr before enclosing with curly braces (r-lib#263). - Avoid checking for hard-coded dot (r-lib#262). - Account for dependency renaming (utf8 changed to enc) (r-lib#264). - Indention of function declaration and closing braces (r-lib#260). - Only remove line break before closing with strict option (r-lib#252).
- Hotfix: utf8 should not be verbose (r-lib#245). - Allow styling of Rmd files(r-lib#233). - Remove duplicate @family (r-lib#244). - Fixing token insertion (r-lib#242). - Capitalize Addin titles (r-lib#241). - Explicit `NULL` creation to make styler compatible with R3.2.0 (r-lib#237). - Improve vignettes (r-lib#232). - Allow exclusion of files with `style_pkg()` and `style_dir()`. - Correct styling with long strings (r-lib#230). - Add tools for re-indenting tokens (r-lib#217). - Math token spacing (r-lib#221). - Remove outdated line and col information (r-lib#218). - Empty input for styling does not cause an error (r-lib#227, r-lib#228). - Tools to insert tokens + application on `if`-`else` clauses (r-lib#212). - Improve example in documentation (r-lib#222). - Fix spacing around in (r-lib#214). - Maintenance: renaming functions / files, extend helper, documentation, if_else etc. (r-lib#204). - Disallow line break after ( for function calls (r-lib#210). - Preserve space between `!` and bang (r-lib#209). - Simplify RStudio Addin (r-lib#208, r-lib#211). - Indention based on square brackets (r-lib#207). - Add vignette on introducing styler (r-lib#203). - Indent function declaration without curly braces correctly (r-lib#202). - Fix indention in if-else statement (r-lib#200). - Sorting key (r-lib#196). - Use safe sequences (r-lib#197). - Fix space between two commas (r-lib#195). - Keep single-line pipes on one line (r-lib#74). - Remove tidyr and dplyr dependency (r-lib#182, r-lib#183, @jimhester). - Fix parsing inconsistency (r-lib#188). - Substitute create filler (r-lib#190). - Introducing class vertical (r-lib#189). - Adapt line break rules (r-lib#172). - Fix `R CMD check` (r-lib#185). - Force argument evaluation for proper error handling (r-lib#179). - Add nonstrict version of set_space_before_comment (r-lib#174). - Add installation instructions to README (r-lib#175). - Addin to style highlighted region (r-lib#143). - Improve spelling (r-lib#168). - Add coverage badge - Change badge from WIP to active - Add the number of files to message (r-lib#166). - Improve documentation (r-lib#164). - Add informative messages while styling files (r-lib#165). - More examples in help file (r-lib#161). - No line breaks after pipe if comment is next token (r-lib#160). - Fixing spacing around `!` (non-bang-bang) (r-lib#157). - Finalize function documentation (r-lib#154). - Review vignette (r-lib#158). - Update bang-bang rule (r-lib#156).
- curly braces don't move a line up if previous token is comment. - wrap parse + transform + serialize in new function. - Speedup of nested styler functions by ~ 4x. - Use multi line instead of line1 / line2 for indention and unindention. - Indent multiple. - add tidyverse rules (indention not yet working properly). - Refactoring and add token before and afterwards to parse table. - Implement post visitor instead of complicated move_up child.
* Tidy up README (r-lib#43). * Fix indention of long operator chains (r-lib#69). * Properly format unary operators (r-lib#38). * Fixing indent multiple - one more time (r-lib#68). * Remove spaces before comma (r-lib#62). * Fixing indention with multiple parentheses (r-lib#57). * data.tree gains unique node IDs for proper printing. * Add `style_file()` function to style a single .R file. * Add RStudio add-in to style active .R file. * hotfix: make `style_pkg()` and `style_src()` work by passing flat argument.
* Correctly deal with comments (spacing before comments, start commen… …t with space) * Test more flexibly (`test_collection()` and friends now support `...`) * Indention based on curly brackets * Spacing across different levels of nesting (e.g. a space after `)` in `function(x) {...}`) * Write tree structure to file via test_collection()` for easy understanding of the nested structure * Outsource tokenise * Account for situations where code does not start on line1 * Correctly style comments * Add style_empty for tailored testing * Initialize indent in create filler * Adapt vignette and documentation to visitor concept * Refine testing to use visiting approach * Parse multiple expressions: Make nested approach wok on multiple expressions too. * Internal: introducing the visitor concept instead of "looping" many times through whole nested structure. * Integrate nested approach in top-level APIs `style_text` and friends via an additional argument. `flat`. * Add tools for scalable testing. Transform *-in.R with a transformer function and check whether result corresponds to *-out.R
PreviousNext