Skip to content
Open
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 NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export(num)
export(obj_sum)
export(pillar)
export(pillar_component)
export(pillar_options)
export(pillar_shaft)
export(set_char_opts)
export(set_num_opts)
Expand Down
27 changes: 17 additions & 10 deletions R/options.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,37 @@
#'
#' Options that affect display of tibble-like output.
#'
#' These options can be set via [options()] and queried via [getOption()].
#' For this, add a `pillar.` prefix (the package name and a dot) to the option name.
#' Example: for an option `foo`, use `options(pillar.foo = value)` to set it
#' and `getOption("pillar.foo")` to retrieve the current value.
#' An option value of `NULL` means that the default is used.
#' All options are available via the `pillar_options` list.
#' The elements of this list are combined getter/setter functions.
#' Calling a function without arguments returns the current value,
#' by providing an argument the current value is set and the old value
#' is returned, invisibly.
#' Setting `local = TRUE` enables the option for the duration of the
#' current stack frame via [rlang::local_options()].
#'
#' @format NULL
#' These options can also be set via [options()] and queried via [getOption()].
#' For this, add a `pillar.` prefix (the package name and a dot) to the option name.
#' Example: for an option `foo`,
#' `pillar_options$foo(value)` is equivalent to
#' `options(pillar.foo = value)`.
#'
#' @export
#' @examples
#' # Default setting:
#' getOption("pillar.sigfig")
#' pillar_options$sigfig()
#' pillar(1.234567)
#'
#' # Change for the duration of the session:
#' old <- options(pillar.sigfig = 6)
#' old <- pillar_options$sigfig(6)
#' pillar(1.234567)
#'
#' # Change back to the original value:
#' options(old)
#' pillar_options$sigfig(old)
#' pillar(1.234567)
#'
#' # Local scope:
#' local({
#' rlang::local_options(pillar.sigfig = 6)
#' pillar_options$sigfig(6, local = TRUE)
#' pillar(1.234567)
#' })
#' pillar(1.234567)
Expand Down
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ navbar:

development:
mode: auto
destination: options

authors:
Kirill Müller:
Expand Down
27 changes: 19 additions & 8 deletions man/pillar_options.Rd

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