diff --git a/R/eval.R b/R/eval.R index 29342a7..8d2b84f 100644 --- a/R/eval.R +++ b/R/eval.R @@ -1,4 +1,4 @@ -#' Evaluate input and return all details of evaluation. +#' Evaluate input and return all details of evaluation #' #' Compare to [eval()], `evaluate` captures all of the #' information necessary to recreate the output as if you had copied and pasted diff --git a/R/hooks.R b/R/hooks.R index 2ca3c24..75411b2 100644 --- a/R/hooks.R +++ b/R/hooks.R @@ -1,6 +1,6 @@ -#' Set hooks. +#' Set and remove hooks #' -#' This wraps the base [setHook()] function to provide a return +#' This interface wraps the base [setHook()] function to provide a return #' value that makes it easy to undo. #' #' @param hooks a named list of hooks - each hook can either be a function or @@ -9,10 +9,14 @@ #' @keywords internal #' @export #' @examples -#' new <- list(before.plot.new = function() print("Plotted!")) -#' hooks <- set_hooks(new) +#' new1 <- list(before.plot.new = function() print("Plotted!")) +#' new2 <- list(before.plot.new = function() print("Plotted Again!")) +#' set_hooks(new1) +#' set_hooks(new2) #' plot(1) -#' set_hooks(hooks, "replace") +#' remove_hooks(new1) +#' plot(1) +#' remove_hooks(new2) #' plot(1) set_hooks <- function(hooks, action = "append") { old <- list() @@ -23,23 +27,8 @@ set_hooks <- function(hooks, action = "append") { invisible(old) } -#' Remove hooks. -#' -#' This provides a way to remove previously set hook values. -#' -#' @inheritParams set_hooks -#' @keywords internal +#' @rdname set_hooks #' @export -#' @examples -#' new1 <- list(before.plot.new = function() print("Plotted!")) -#' new2 <- list(before.plot.new = function() print("Plotted Again!")) -#' set_hooks(new1) -#' set_hooks(new2) -#' plot(1) -#' remove_hooks(new1) -#' plot(1) -#' remove_hooks(new2) -#' plot(1) remove_hooks <- function(hooks) { for (hook_name in names(hooks)) { hook <- getHook(hook_name) @@ -49,4 +38,3 @@ remove_hooks <- function(hooks) { setHook(hook_name, hook, "replace") } } - diff --git a/R/output.R b/R/output.R index 6bda07a..c5e79cd 100644 --- a/R/output.R +++ b/R/output.R @@ -1,18 +1,23 @@ #' Object class tests -#' @export is.message is.warning is.error is.value is.source is.recordedplot -#' @aliases is.message is.warning is.error is.value is.source is.recordedplot +#' #' @keywords internal #' @rdname is.message +#' @export is.message <- function(x) inherits(x, "message") #' @rdname is.message +#' @export is.warning <- function(x) inherits(x, "warning") #' @rdname is.message +#' @export is.error <- function(x) inherits(x, "error") #' @rdname is.message +#' @export is.value <- function(x) inherits(x, "value") #' @rdname is.message +#' @export is.source <- function(x) inherits(x, "source") #' @rdname is.message +#' @export is.recordedplot <- function(x) inherits(x, "recordedplot") new_value <- function(value, visible = TRUE) { @@ -42,7 +47,7 @@ classes <- function(x) vapply(x, function(x) class(x)[1], character(1)) render <- function(x) if (isS4(x)) methods::show(x) else print(x) -#' Custom output handlers. +#' Custom output handlers #' #' An `output_handler` handles the results of [evaluate()], #' including the values, graphics, conditions. Each type of output is handled by diff --git a/R/parse.R b/R/parse.R index c6b1d0a..b896a9d 100644 --- a/R/parse.R +++ b/R/parse.R @@ -1,4 +1,4 @@ -#' Parse, retaining comments. +#' Parse, retaining comments #' #' Works very similarly to parse, but also keeps original formatting and #' comments. diff --git a/R/replay.R b/R/replay.R index e37820b..d0b16c2 100644 --- a/R/replay.R +++ b/R/replay.R @@ -1,4 +1,4 @@ -#' Replay a list of evaluated results. +#' Replay a list of evaluated results #' #' Replay a list of evaluated results, as if you'd run them in an R #' terminal. diff --git a/R/traceback.R b/R/traceback.R index 178149e..6c6edb5 100644 --- a/R/traceback.R +++ b/R/traceback.R @@ -1,4 +1,4 @@ -#' Generate a traceback from a list of calls. +#' Generate a traceback from a list of calls #' #' @param callstack stack of calls, as generated by (e.g.) #' [base::sys.calls()] @@ -17,7 +17,7 @@ create_traceback <- function(callstack) { calls } -#' Try, capturing stack on error. +#' Try, capturing stack on error #' #' This is a variant of [tryCatch()] that also captures the call #' stack if an error occurs. diff --git a/R/watcher.R b/R/watcher.R index 1aa3bd3..1864f62 100644 --- a/R/watcher.R +++ b/R/watcher.R @@ -1,4 +1,4 @@ -#' Watch for changes in output, text and graphical. +#' Watch for changes in output, text and graphics #' #' @param debug activate debug mode where output will be both printed to #' screen and captured. diff --git a/man/create_traceback.Rd b/man/create_traceback.Rd index 17d690c..5a3a9dd 100644 --- a/man/create_traceback.Rd +++ b/man/create_traceback.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/traceback.R \name{create_traceback} \alias{create_traceback} -\title{Generate a traceback from a list of calls.} +\title{Generate a traceback from a list of calls} \usage{ create_traceback(callstack) } @@ -11,6 +11,6 @@ create_traceback(callstack) \code{\link[base:sys.parent]{base::sys.calls()}}} } \description{ -Generate a traceback from a list of calls. +Generate a traceback from a list of calls } \keyword{internal} diff --git a/man/evaluate.Rd b/man/evaluate.Rd index 84333a0..49a3691 100644 --- a/man/evaluate.Rd +++ b/man/evaluate.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/eval.R \name{evaluate} \alias{evaluate} -\title{Evaluate input and return all details of evaluation.} +\title{Evaluate input and return all details of evaluation} \usage{ evaluate( input, diff --git a/man/new_output_handler.Rd b/man/new_output_handler.Rd index aa312a8..798a7a3 100644 --- a/man/new_output_handler.Rd +++ b/man/new_output_handler.Rd @@ -3,7 +3,7 @@ \name{new_output_handler} \alias{new_output_handler} \alias{output_handler} -\title{Custom output handlers.} +\title{Custom output handlers} \usage{ new_output_handler( source = identity, diff --git a/man/parse_all.Rd b/man/parse_all.Rd index 7ad918f..7b8a0f1 100644 --- a/man/parse_all.Rd +++ b/man/parse_all.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/parse.R \name{parse_all} \alias{parse_all} -\title{Parse, retaining comments.} +\title{Parse, retaining comments} \usage{ parse_all(x, filename = NULL, allow_error = FALSE) } diff --git a/man/remove_hooks.Rd b/man/remove_hooks.Rd deleted file mode 100644 index 4a209fe..0000000 --- a/man/remove_hooks.Rd +++ /dev/null @@ -1,27 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/hooks.R -\name{remove_hooks} -\alias{remove_hooks} -\title{Remove hooks.} -\usage{ -remove_hooks(hooks) -} -\arguments{ -\item{hooks}{a named list of hooks - each hook can either be a function or -a list of functions.} -} -\description{ -This provides a way to remove previously set hook values. -} -\examples{ -new1 <- list(before.plot.new = function() print("Plotted!")) -new2 <- list(before.plot.new = function() print("Plotted Again!")) -set_hooks(new1) -set_hooks(new2) -plot(1) -remove_hooks(new1) -plot(1) -remove_hooks(new2) -plot(1) -} -\keyword{internal} diff --git a/man/replay.Rd b/man/replay.Rd index 6d86bb3..b9f18b2 100644 --- a/man/replay.Rd +++ b/man/replay.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/replay.R \name{replay} \alias{replay} -\title{Replay a list of evaluated results.} +\title{Replay a list of evaluated results} \usage{ replay(x) } diff --git a/man/set_hooks.Rd b/man/set_hooks.Rd index 7d6f251..d103f1e 100644 --- a/man/set_hooks.Rd +++ b/man/set_hooks.Rd @@ -2,9 +2,12 @@ % Please edit documentation in R/hooks.R \name{set_hooks} \alias{set_hooks} -\title{Set hooks.} +\alias{remove_hooks} +\title{Set and remove hooks} \usage{ set_hooks(hooks, action = "append") + +remove_hooks(hooks) } \arguments{ \item{hooks}{a named list of hooks - each hook can either be a function or @@ -13,14 +16,18 @@ a list of functions.} \item{action}{\code{"replace"}, \code{"append"} or \code{"prepend"}} } \description{ -This wraps the base \code{\link[=setHook]{setHook()}} function to provide a return +This interface wraps the base \code{\link[=setHook]{setHook()}} function to provide a return value that makes it easy to undo. } \examples{ -new <- list(before.plot.new = function() print("Plotted!")) -hooks <- set_hooks(new) +new1 <- list(before.plot.new = function() print("Plotted!")) +new2 <- list(before.plot.new = function() print("Plotted Again!")) +set_hooks(new1) +set_hooks(new2) +plot(1) +remove_hooks(new1) plot(1) -set_hooks(hooks, "replace") +remove_hooks(new2) plot(1) } \keyword{internal} diff --git a/man/try_capture_stack.Rd b/man/try_capture_stack.Rd index 6441d1c..ef2ffd4 100644 --- a/man/try_capture_stack.Rd +++ b/man/try_capture_stack.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/traceback.R \name{try_capture_stack} \alias{try_capture_stack} -\title{Try, capturing stack on error.} +\title{Try, capturing stack on error} \usage{ try_capture_stack(quoted_code, env) } diff --git a/man/watchout.Rd b/man/watchout.Rd index dc86766..d5afa1a 100644 --- a/man/watchout.Rd +++ b/man/watchout.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/watcher.R \name{watchout} \alias{watchout} -\title{Watch for changes in output, text and graphical.} +\title{Watch for changes in output, text and graphics} \usage{ watchout(debug = FALSE) } @@ -15,6 +15,6 @@ list containing four functions: \code{get_new}, \code{pause}, \code{unpause}, \code{close}. } \description{ -Watch for changes in output, text and graphical. +Watch for changes in output, text and graphics } \keyword{internal}