Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

docs: Document package options #1193

Merged
merged 3 commits into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Collate:
'io.R'
'nest.R'
'nested-to-tree.R'
'options.R'
'parse.R'
'reindent.R'
'token-define.R'
Expand Down
56 changes: 56 additions & 0 deletions R/options.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#' Package options
#'
#' These options can be set via [options()] and queried via [getOption()].
#' For this, add a `styler.` prefix (the package name and a dot) to the option name.
#' Example: for an option `foo`, use `options(styler.foo = value)` to set it
#' and `getOption("styler.foo")` to retrieve the current value.
#' An option value of `NULL` means that the default is used.
#'
#' @usage NULL
#' @format NULL
#'
#' @name styler_options
#'
#' @examplesIf FALSE
#' getOption("styler.ignore_alignment")
#' options(
#' styler.ignore_alignment = TRUE,
#' styler.quiet = TRUE
#' )
#' getOption("styler.ignore_alignment")
#'
#' @section Options for the styler package:
#'
#' - `styler.addins_style_transformer`: character.
#' The name of the style transformer to use in the addins.
#' (default: `"styler::tidyverse_style()"`)
#'
#' - `styler.cache_name`: character.
#' The name of the styler cache to use.
#' (default: `r unlist(unname(read.dcf("DESCRIPTION")[, "Version"]), use.names = FALSE)`)
#'
#' - `styler.cache_root`: character.
#' The directory where the cache files are stored. For more, see `help("caching")`.
#' (default: `NULL`)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could link help("caching") here.

#'
#' - `styler.colored_print.vertical`: logical.
#' It decides whether or not the output should be colored with `prettycode::highlight()`.
#' (default: `TRUE`)
#'
#' - `styler.ignore_alignment`: logical.
#' If `TRUE`, alignment, when detected, is ignored. For more, see `vignette("detect-alignment")`.
#' (default: `FALSE`)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could link vignette("detect-alignment") here.

#'
#' - `styler.ignore_start`, `styler.ignore_stop`: character.
#' Regular expressions to ignore lines that match them. For more, see `help("stylerignore")`.
#' (default: `"styler: off"` and `"styler: on"`, respectively)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can link help("stylerignore") here.

#'
#' - `styler.quiet`: logical.
#' It decides whether or not to print an informative message about what the function is doing.
#' If `TRUE`, no output is printed.
#' (default: `FALSE`)
#'
#' - `styler.test_dir_writable`: logical.
#' If `TRUE`, the package tests whether the directory is writable.
#' (default: `TRUE`)
NULL
2 changes: 1 addition & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
op <- options()
op.styler <- list(
styler.addins_style_transformer = "styler::tidyverse_style()",
styler.cache_root = NULL,
styler.cache_name = styler_version,
styler.cache_root = NULL,
styler.colored_print.vertical = TRUE,
styler.ignore_alignment = FALSE,
styler.ignore_start = .default_ignore_start,
Expand Down
1 change: 1 addition & 0 deletions _pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ reference:
- style_pkg
- style_dir
- styler_addins
- styler_options
- title: "Fine-tune styling"
desc: "Customize style guides"
- contents:
Expand Down
53 changes: 53 additions & 0 deletions man/styler_options.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading