style_box_use_text {box.linters} | R Documentation |
Style the box::use() calls of source code text
Description
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()
)
Arguments
text |
Source code in text format |
indent_spaces |
Number of spaces per indent level |
trailing_commas_func |
A boolean to activate adding a trailing comma to the end of the lists of functions to attach. |
colored |
Boolean. For syntax highlighting using {prettycode} |
style |
A style from {prettycode} |
Examples
code <- "box::use(stringr[str_trim, str_pad], dplyr)"
style_box_use_text(code)
code <- "box::use(stringr[
str_trim,
str_pad
],
shiny[...], # nolint
dplyr[alias = select, mutate], alias = tidyr
path/to/module)
"
style_box_use_text(code)
style_box_use_text(code, trailing_commas_func = TRUE)