Skip to content

Commit 932437b

Browse files
Merge pull request #1193 from r-lib/1185-docs-options
docs: Document package options
2 parents 9416b3b + 040eeed commit 932437b

File tree

5 files changed

+112
-1
lines changed

5 files changed

+112
-1
lines changed

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Collate:
6969
'io.R'
7070
'nest.R'
7171
'nested-to-tree.R'
72+
'options.R'
7273
'parse.R'
7374
'reindent.R'
7475
'token-define.R'

R/options.R

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#' Package options
2+
#'
3+
#' These options can be set via [options()] and queried via [getOption()].
4+
#' For this, add a `styler.` prefix (the package name and a dot) to the option name.
5+
#' Example: for an option `foo`, use `options(styler.foo = value)` to set it
6+
#' and `getOption("styler.foo")` to retrieve the current value.
7+
#' An option value of `NULL` means that the default is used.
8+
#'
9+
#' @usage NULL
10+
#' @format NULL
11+
#'
12+
#' @name styler_options
13+
#'
14+
#' @examplesIf FALSE
15+
#' getOption("styler.ignore_alignment")
16+
#' options(
17+
#' styler.ignore_alignment = TRUE,
18+
#' styler.quiet = TRUE
19+
#' )
20+
#' getOption("styler.ignore_alignment")
21+
#'
22+
#' @section Options for the styler package:
23+
#'
24+
#' - `styler.addins_style_transformer`: character.
25+
#' The name of the style transformer to use in the addins.
26+
#' (default: `"styler::tidyverse_style()"`)
27+
#'
28+
#' - `styler.cache_name`: character.
29+
#' The name of the styler cache to use.
30+
#' (default: `r unlist(unname(read.dcf("DESCRIPTION")[, "Version"]), use.names = FALSE)`)
31+
#'
32+
#' - `styler.cache_root`: character.
33+
#' The directory where the cache files are stored. For more, see `help("caching")`.
34+
#' (default: `NULL`)
35+
#'
36+
#' - `styler.colored_print.vertical`: logical.
37+
#' It decides whether or not the output should be colored with `prettycode::highlight()`.
38+
#' (default: `TRUE`)
39+
#'
40+
#' - `styler.ignore_alignment`: logical.
41+
#' If `TRUE`, alignment, when detected, is ignored. For more, see `vignette("detect-alignment")`.
42+
#' (default: `FALSE`)
43+
#'
44+
#' - `styler.ignore_start`, `styler.ignore_stop`: character.
45+
#' Regular expressions to ignore lines that match them. For more, see `help("stylerignore")`.
46+
#' (default: `"styler: off"` and `"styler: on"`, respectively)
47+
#'
48+
#' - `styler.quiet`: logical.
49+
#' It decides whether or not to print an informative message about what the function is doing.
50+
#' If `TRUE`, no output is printed.
51+
#' (default: `FALSE`)
52+
#'
53+
#' - `styler.test_dir_writable`: logical.
54+
#' If `TRUE`, the package tests whether the directory is writable.
55+
#' (default: `TRUE`)
56+
NULL

R/zzz.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
op <- options()
77
op.styler <- list(
88
styler.addins_style_transformer = "styler::tidyverse_style()",
9-
styler.cache_root = NULL,
109
styler.cache_name = styler_version,
10+
styler.cache_root = NULL,
1111
styler.colored_print.vertical = TRUE,
1212
styler.ignore_alignment = FALSE,
1313
styler.ignore_start = .default_ignore_start,

_pkgdown.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ reference:
1111
- style_pkg
1212
- style_dir
1313
- styler_addins
14+
- styler_options
1415
- title: "Fine-tune styling"
1516
desc: "Customize style guides"
1617
- contents:

man/styler_options.Rd

Lines changed: 53 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)