This function uses styler::tidyverse_style() and modifies it to make it Bioconductor friendly. The full Bioconductor coding style is described at https://bioconductor.org/developers/how-to/coding-style/ and it shares many properties with the Tidyverse coding style guide https://style.tidyverse.org/. This function defines the transformers code that you can then use with other styler functions such as styler::style_pkg().

bioc_style(indent_by = 4, ...)

Arguments

indent_by

How many spaces of indention should be inserted after operators such as '('. Unlike styler::tidyverse_style(), the default is 4 to conform with the Bioconductor coding style.

...

Other arguments passed to styler::tidyverse_style().

Value

A list() object with the information required by functions in the transformers argument in the styler package functions such as styler::style_pkg().

Details

The styler package seems to be more actively maintained and better performance than formatR, though that package can also be useful. This function does not produce an exact Bioconductor coding style, but it gets you close enough! =)

For more details on how this function came to be, check https://github.com/r-lib/styler/issues/636 https://github.com/Bioconductor/BiocCheck/issues/57 https://github.com/Bioconductor/bioconductor.org/issues/54

Examples

if (FALSE) { # \dontrun{
## Run these functions in your package
styler::style_pkg(transformers = biocthis::bioc_style())
styler::style_dir(usethis::proj_path("dev"), transformers = biocthis::bioc_style())
} # }

## Create an example package for illustrative purposes.
## Note: you do not need to run this for your own package!
pkgdir <- biocthis_example_pkg()
#>  Creating /tmp/RtmpKDAe9y/biocthisexample/.
#>  Setting active project to "/tmp/RtmpKDAe9y/biocthisexample".
#>  Creating R/.
#>  Writing DESCRIPTION.
#> Package: biocthisexample
#> Title: What the Package Does (One Line, Title Case)
#> Version: 0.0.0.9000
#> Authors@R (parsed):
#>     * First Last <first.last@example.com> [aut, cre]
#> Description: What the package does (one paragraph).
#> License: `use_mit_license()`, `use_gpl3_license()` or friends to
#>     pick a license
#> Encoding: UTF-8
#> Roxygen: list(markdown = TRUE)
#> RoxygenNote: 7.3.2
#>  Writing NAMESPACE.
#>  Setting active project to "<no active project>".
#>  Setting active project to "/tmp/RtmpKDAe9y/biocthisexample".

## Automatically style the example package
styler::style_pkg(pkgdir, transformers = biocthis::bioc_style())
#> ────────────────────────────────────────
#> Status	Count	Legend 
#> ✔ 	0	File unchanged.
#> ℹ 	0	File changed.
#> ✖ 	0	Styling threw an error.
#> ────────────────────────────────────────