Skip to content

Commit

Permalink
docs: Define type_sum.accel() only in help page to avoid silent err…
Browse files Browse the repository at this point in the history
…ors when loading (#721)
  • Loading branch information
krlmlr authored Dec 24, 2024
1 parent 15e84c2 commit 2c8b098
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
6 changes: 5 additions & 1 deletion R/type.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,18 @@ format_full_pillar_type <- function(x) {
#' @export
#' @examples
#' # Default method: show the type with angle brackets
#' format_type_sum(1, NULL)
#' writeLines(format_type_sum("dbl", width = NULL))
#' pillar(1)
#'
#' # AsIs method: show the type without angle brackets
#' type_sum.accel <- function(x) {
#' I("kg m/s^2")
#' }
#'
#' # Typically done through NAMESPACE
#' # (perhaps with an @export directive in roxygen2)
#' registerS3method("type_sum", "accel", type_sum.accel)
#'
#' accel <- structure(9.81, class = "accel")
#' pillar(accel)
format_type_sum <- function(x, width, ...) {
Expand Down
12 changes: 0 additions & 12 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@
#' @importFrom cli symbol ansi_strwrap
NULL

# https://github.com/r-lib/pkgdown/issues/1540
if (Sys.getenv("IN_PKGDOWN") != "") {
type_sum.accel <- function(x) {
I("kg m/s^2")
}
}

# nolint start
.onLoad <- function(libname, pkgname) {
# nolint end
Expand All @@ -67,11 +60,6 @@ if (Sys.getenv("IN_PKGDOWN") != "") {
debug_info()
}

# https://github.com/r-lib/pkgdown/issues/1540
if (Sys.getenv("IN_PKGDOWN") != "") {
s3_register("pillar::type_sum", "accel")
}

invisible()
}

Expand Down
6 changes: 5 additions & 1 deletion man/format_type_sum.Rd

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

0 comments on commit 2c8b098

Please sign in to comment.