Skip to content

Commit

Permalink
Merge pull request #277 from r-lib/use-rstudioapi
Browse files Browse the repository at this point in the history
Check if rstudioapi is available
  • Loading branch information
jennybc authored May 3, 2024
2 parents 7556a3f + 0e94bb1 commit f7fc41f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/dev-help.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,7 @@ cat_line <- function(...) {
is_rstudio <- function() {
is_string(.Platform$GUI, "RStudio")
}

rstudioapi_available <- function() {
is_installed("rstudioapi") && rstudioapi::isAvailable()
}

0 comments on commit f7fc41f

Please sign in to comment.