Distribute custom style guides

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
styler::cache_deactivate()
options(styler.colored_print.vertical = FALSE)

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 = "';'")
)

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.



Try the styler package in your browser

Any scripts or data that you put into this service are public.

styler documentation built on Aug. 29, 2023, 5:10 p.m.