Skip to content

Commit

Permalink
Fix RStudio help event
Browse files Browse the repository at this point in the history
Follow up to #205 for #120
  • Loading branch information
lionel- committed Jun 2, 2022
1 parent 7f743b2 commit e3c282a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions R/dev-help.r
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@ print.dev_topic <- function(x, ...) {
topic_write_text(x, out_path)
file.show(out_path, title = paste(x$pkg, basename(x$path), sep = ":"))
} else if (type == "html") {
topic_write_html(x, out_path)
utils::browseURL(out_path)
if (is_installed("rstudioapi") && rstudioapi::hasFun("previewRd")) {
rstudioapi::callFun("previewRd", x$path)
} else {
topic_write_html(x, out_path)
utils::browseURL(out_path)
}
}
}

Expand All @@ -83,11 +87,6 @@ topic_write_text <- function(x, path) {
}

topic_write_html <- function(x, path) {
if (is_installed("rstudioapi") && rstudioapi::hasFun("previewRd")) {
rstudioapi::callFun("previewRd", x$path)
return(invisible())
}

macros <- load_rd_macros(dirname(dirname(x$path)))

tools::Rd2HTML(
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-help.r
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ test_that("complex expressions are checked", {
test_that("can use macros in other packages (#120)", {
skip_if_not_installed("mathjaxr")

load_all("testMacroDownstream")
load_all(test_path("testMacroDownstream"))

topic <- dev_help("macro_downstream")
text_lines <- topic_lines(topic, "text")
Expand Down

0 comments on commit e3c282a

Please sign in to comment.