Skip to content

Commit 942cebe

Browse files
committed
doc updates
1 parent 54854a7 commit 942cebe

File tree

5 files changed

+40
-22
lines changed

5 files changed

+40
-22
lines changed

R/code.R

+11-11
Original file line numberDiff line numberDiff line change
@@ -95,22 +95,22 @@ callFun <- function(fname, ...) {
9595
return(callRemote(sys.call(), parent.frame()))
9696

9797
verifyAvailable()
98-
if (usingTools())
99-
found <- exists(toolsName(fname), envir = toolsEnv(), mode = "function")
100-
else
101-
found <- exists(fname, envir = asNamespace("rstudio"), mode = "function")
102-
if (!found)
103-
stop("Function ", fname, " not found in RStudio", call. = FALSE)
10498

105-
f <- findFun(fname, mode = "function")
99+
# get reference to RStudio function
100+
f <- tryCatch(findFun(fname, mode = "function"), error = identity)
101+
if (inherits(f, "error"))
102+
stop("Function ", fname, " not found in RStudio", call. = FALSE)
106103

104+
# drop arguments that aren't accepted by RStudio
105+
# (ensure backwards-compatibility with older versions of RStudio)
107106
args <- list(...)
108107
if (!"..." %in% names(formals(f)))
109-
{
110-
while (length(args) > length(formals(f)))
111-
args <- args[-length(args)]
112-
}
108+
if (length(args) > length(formals(f)))
109+
length(args) <- length(formals(f))
110+
111+
# invoke the function
113112
do.call(f, args)
113+
114114
}
115115

116116

R/remote.R

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11

2-
#' Is this a job
2+
#' Detect RStudio Jobs
3+
#'
4+
#' Use this function to detect whether RStudio is running an R "job".
5+
#' These jobs are normally used for actions taken in the Jobs tab, as well
6+
#' as within the \R build pane.
7+
#'
8+
#' This function is primarily intended to be used by package authors, who
9+
#' need to customize the behavior of their methods when run within an
10+
#' RStudio job.
11+
#'
12+
#' @return Boolean; `TRUE` if this is an RStudio job.
313
#'
4-
#' @return TRUE if this is a job
514
#' @export
615
isJob <- function() {
716
!is.na(Sys.getenv("RSTUDIOAPI_IPC_REQUESTS_FILE", unset = NA))

R/stubs.R

+4-3
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,9 @@ savePlotAsImage <- function(file,
336336
#'
337337
#' @param code The \R code to be executed, as a character vector.
338338
#'
339-
#' @param execute Boolean; execute the code immediately or just enter the text
340-
#' into the console?
339+
#' @param execute Boolean; should the code be executed after being submitted
340+
#' to the console? If `FALSE`, `code` is submitted to the console but is
341+
#' not executed.
341342
#'
342343
#' @param echo Boolean; echo the code in the console as it is executed?
343344
#'
@@ -351,7 +352,7 @@ savePlotAsImage <- function(file,
351352
#' @examples
352353
#'
353354
#' \dontrun{
354-
#' rstudioapi::sendToConsole(".Platform", execute = TRUE)
355+
#' rstudioapi::sendToConsole(".Platform", execute = FALSE, animate = TRUE)
355356
#' }
356357
#'
357358
#'

man/isJob.Rd

+10-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/sendToConsole.Rd

+4-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)