Skip to contents

This is adapted from https://github.com/gadenbuie/grkstyle. It differs in that it will break apart long lines regardless of their initial line breaks to try and fit them into a set width. It does not unbreak lines.

Usage

style_text(text, ..., transformers = pkgtools_style_transformer(...))

Arguments

text

A character vector with text to style.

...

Arguments passed on to styler::style_text, pkgtools_style_transformer

style

A function that creates a style guide to use, by default tidyverse_style. Not used further except to construct the argument transformers. See style_guides() for details.

include_roxygen_examples

Whether or not to style code in roxygen examples.

base_indention

Integer scalar indicating by how many spaces the whole output text should be indented. Note that this is not the same as splitting by line and add a base_indention spaces before the code in the case multi-line strings are present. See 'Examples'.

width

the max width of the code (excludes indent hence approximate)

transformers

A set of transformer functions. This argument is most conveniently constructed via the style argument and .... See 'Examples'.

Value

the formatted code

Examples

if (FALSE) {
  style_text("my_function(very_long_argument_name = some_value)")
}