Distribute custom style guides

This vignette describes how you can distribute your own style guide. It builds on vignette("customizing_styler") and assumes you understand how to create a style guide with create_style_guide().

Reference implementations

There are a few packages that implement a third-party style guide that are maintained by styler contributors:

Other available style guides include:

To start out, you can use the GitHub Template for third-party style guides that has already the right directory structure and patterns described below in place.

You made one too? Please submit a PR to include it in the list.

Design patterns

The style guides mentioned above follow best practices and can serve as a good and rather minimal example of how to implement your own style guide. Most importantly, these two packages:

When creating a custom style guide and distribute it, we want to quickly recall important arguments for create_style_guide() from the docs:

styler::specify_transformers_drop(
  spaces = list(style_space_around_tilde = "'~'"),
  tokens = list(resolve_semicolon = "';'")
)
#> $space
#> $space$style_space_around_tilde
#> [1] "'~'"
#> 
#> 
#> $indention
#> NULL
#> 
#> $line_break
#> NULL
#> 
#> $token
#> $token$resolve_semicolon
#> [1] "';'"

Where the name must correspond to the transformer function in question and the value is the token that must be absent in order to drop the transformer.