From ab000fb8f559e3559f30662670f3a13d79dc77ba Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Mon, 6 Jul 2026 17:33:07 -0500 Subject: [PATCH] Use rdtools --- DESCRIPTION | 3 +++ R/topics-external.R | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 4e1f6b215..d133e2303 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -38,6 +38,7 @@ Imports: openssl, purrr (>= 1.0.0), ragg (>= 1.4.0), + rdtools, rlang (>= 1.1.4), rmarkdown (>= 2.27), tibble, @@ -64,6 +65,8 @@ Suggests: sass, testthat (>= 3.1.3), tools +Remotes: + r-lib/rdtools VignetteBuilder: knitr, quarto diff --git a/R/topics-external.R b/R/topics-external.R index d853426d3..624fb133c 100644 --- a/R/topics-external.R +++ b/R/topics-external.R @@ -26,21 +26,21 @@ ext_topics <- function(match_strings) { ) } -# Adapted from roxygen2::get_rd_from_help +# Fetches the parsed Rd for an external package's topic get_rd_from_help <- function(package, alias) { call <- quote(build_reference_index()) check_installed(package, "as it's used in the reference index.", call = call) - help <- utils::help((alias), (package)) - if (length(help) == 0) { - fun <- paste0(package, "::", alias) - cli::cli_abort( - "Could not find documentation for {.fn {fun}}.", - call = call - ) - return() - } + rd <- tryCatch( + rdtools::topic_rd(alias, package), + error = function(e) { + fun <- paste0(package, "::", alias) + cli::cli_abort( + "Could not find documentation for {.fn {fun}}.", + call = call + ) + } + ) - out <- get(".getHelpFile", envir = asNamespace("utils"))(help) - set_classes(out) + set_classes(rd) }