Package 'tergo'

Title: Style Your Code Fast
Description: Style your code FAST.
Authors: Konrad Pagacz [aut, cre], The authors of the dependency Rust crates [ctb] (see inst/AUTHORS file for details)
Maintainer: Konrad Pagacz <[email protected]>
License: MIT + file LICENSE
Version: 0.1.4.9001
Built: 2024-11-11 05:17:10 UTC
Source: https://github.com/kpagacz/tergo

Help Index


Get the default configuration

Description

This configuration is used by the styling functions if no value is provided for the configuration keys.

Usage

get_default_config()

Value

list with the default configuration

Examples

get_default_config()

Style a package

Description

Style a package

Usage

style(config_file = "tergo.toml", configuration = list(), ...)

Arguments

config_file

(character) The path to the configuration file

configuration

(list) The path to the configuration for formatting

...

additional parameters to style_pkg()

Details

Configuration is read from a file named tergo.toml in the root of the package. The precedence of the configuration is (from the highest to lowest):

  1. The configuration passed to the function.

  2. The configuration file.

Examples

style()
style(config_file = "tergo.toml", configuration = list())

Style a file

Description

Style a file

Usage

style_file(file, configuration = list())

Arguments

file

(character) the file to format

configuration

(list) The path to the configuration for formatting


Style a package

Description

Style a package

Usage

style_pkg(
  path = ".",
  config_file = "tergo.toml",
  configuration = list(),
  force = FALSE,
  extensions = c(".R", ".r")
)

Arguments

path

(character) The path to the package.

config_file

(character) The path to the configuration file

configuration

(list) The path to the configuration for formatting

force

(⁠logical(1⁠) Whether to format the files even if no package was found. TRUE - format the .R and .r files found in the directory (recursive). FALSE exit without formatting anything.

extensions

(character) The extensions of the files to format.


Style text

Description

Style text

Usage

style_text(text, configuration = list())

Arguments

text

(character) the text to style

configuration

(list) The path to the configuration for formatting

Details

This function is vectorized.

Value

(character) the text formatted as R code

Examples

code <- "function(){}"
style_text(code)

code <- c("function(){}", "A<-7")
style_text(code)