From 0e94bb142caa5afb135849b505ad151eca3c5adc Mon Sep 17 00:00:00 2001 From: Jenny Bryan Date: Thu, 2 May 2024 12:10:41 -0700 Subject: [PATCH] Use rstudioapi to determine if rstudioapi is available --- R/dev-help.R | 2 +- R/utils.R | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/R/dev-help.R b/R/dev-help.R index bb334d8b..80d30173 100644 --- a/R/dev-help.R +++ b/R/dev-help.R @@ -89,7 +89,7 @@ print.dev_topic <- function(x, ...) { type <- arg_match0(x$type %||% "text", c("text", "html")) # Use rstudio's previewRd() if possible - if (type == "html" && is_rstudio() && is_installed("rstudioapi")) { + if (type == "html" && rstudioapi_available()) { # If the package has Rd macros, this needs a version of rstudio # that loads them, see rstudio/rstudio#12111 version_needed <- if (has_rd_macros(dirname(dirname(x$path)))) "2022.12.0.256" diff --git a/R/utils.R b/R/utils.R index d0214306..fa7ae276 100644 --- a/R/utils.R +++ b/R/utils.R @@ -203,3 +203,7 @@ cat_line <- function(...) { is_rstudio <- function() { is_string(.Platform$GUI, "RStudio") } + +rstudioapi_available <- function() { + is_installed("rstudioapi") && rstudioapi::isAvailable() +}