Styles box::use()
calls.
All packages are called under one
box::use()
.All modules are called under one
box::use()
.Package and module levels are re-formatted to multiple lines. One package per line.
Packages and modules are sorted alphabetically, ignoring the aliases.
Functions attached in a single line retain the single line format.
Functions attached in multiple lines retain the multiple line format.
Functions are sorted alphabetically, ignoring the aliases.
A trailing comma is added to packages, modules, and functions.
Usage
style_box_use_text(
text,
indent_spaces = 2,
trailing_commas_func = FALSE,
colored = getOption("styler.colored_print.vertical", default = FALSE),
style = prettycode::default_style()
)
Examples
code <- "box::use(stringr[str_trim, str_pad], dplyr)"
style_box_use_text(code)
#> box::use(
#> dplyr,
#> stringr[str_pad, str_trim],
#> )
#>
#> Warning: Changes were made. Please review the modifications made. Comments near
#> box::use() are moved to the top of the file.
code <- "box::use(stringr[
str_trim,
str_pad
],
shiny[...], # nolint
dplyr[alias = select, mutate], alias = tidyr
path/to/module)
"
style_box_use_text(code)
#> box::use(
#> dplyr[mutate, alias = select],
#> shiny[...], # nolint
#> stringr[
#> str_pad,
#> str_trim
#> ],
#> alias = tidyr,
#> )
#>
#> box::use(
#> path/to/module,
#> )
#>
#> Warning: Changes were made. Please review the modifications made. Comments near
#> box::use() are moved to the top of the file.
style_box_use_text(code, trailing_commas_func = TRUE)
#> box::use(
#> dplyr[mutate, alias = select, ],
#> shiny[...], # nolint
#> stringr[
#> str_pad,
#> str_trim,
#> ],
#> alias = tidyr,
#> )
#>
#> box::use(
#> path/to/module,
#> )
#>
#> Warning: Changes were made. Please review the modifications made. Comments near
#> box::use() are moved to the top of the file.