Skip to content

Commit

Permalink
Use rstudio::previewRd, if available.
Browse files Browse the repository at this point in the history
Closes #322
  • Loading branch information
hadley committed Oct 7, 2013
1 parent 2adcc2e commit c8d4d2d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Suggests:
BiocInstaller,
Rcpp (>= 0.10.0),
MASS,
knitr
knitr,
rstudio
License: GPL (>= 2)
Collate:
'R.r'
Expand Down
7 changes: 6 additions & 1 deletion R/dev-help.r
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ dev_help <- function(topic, stage = "render", type = getOption("help_type")) {
}

pkg <- basename(names(path)[1])
view_rd(path, pkg, stage = stage, type = type)
if (rstudio_has("previewRd")) {
rstudio::previewRd(path)
} else {
view_rd(path, pkg, stage = stage, type = type)
}

}


Expand Down
7 changes: 7 additions & 0 deletions R/utils.r
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,10 @@ ends_with_newline <- function(path) {
lastByte <- readBin(conn, "raw", n = 1)
lastByte == 0x0a
}

rstudio_has <- function(f = NULL) {
if (is.null(f)) return("tools:rstudio" %in% search())

exists(as.character(f), asNamespace("rstudio"))

}

0 comments on commit c8d4d2d

Please sign in to comment.