The goal of semicoloner is format code according to one rule: Put a semi-colon after every expression. It is an example for a custom {styler} style guide.
You can install the released version of semicoloner from CRAN with:
remotes::install_github("lorenzwalthert/semicoloner")
This is a basic example which shows you how to solve a common problem:
library(semicoloner)
cache_deactivate()
#> Deactivated cache.
text <- 'communicate_warning <- function(changed, transformers) {
if (any(changed, na.rm = TRUE) &&
!can_verify_roundtrip(transformers) &&
!getOption("styler.quiet", FALSE)
) {
cat("Please review the changes carefully!", fill = TRUE)
}
}
a
b
c /
3
d + 3
'
style_text(text)
#> communicate_warning <- function(changed, transformers) {
#> if (any(changed, na.rm = TRUE) &&
#> !can_verify_roundtrip(transformers) &&
#> !getOption("styler.quiet", FALSE)
#> ) {
#> cat("Please review the changes carefully!", fill = TRUE);
#> };
#> };
#> a;
#> b;
#> c /
#> 3;
#> d + 3;
- re-export all exported functions from {styler},
purrr::partial()
style guide arguments with third-party style guide. - implement
more_args
andtransformer_drop
increate_style_guide()
.