Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ Config/Needs/website: tidyverse/tidytemplate
Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
Collate:
'aaa.R'
'collate.R'
Expand Down Expand Up @@ -71,3 +70,4 @@ Collate:
'torture.R'
'utils.R'
'with.R'
Config/roxygen2/version: 8.1.0
80 changes: 70 additions & 10 deletions R/devices.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ with_bmp <- function(new, code, ...) {

#' @rdname devices
#' @export
local_bmp <- function(new, ..., .local_envir = parent.frame()) {
local_bmp <- function(new = NULL, ..., .local_envir = parent.frame()) {
new <- new %||%
local_tempfile(
.local_envir = .local_envir,
pattern = "withr_file",
fileext = ".bmp"
)
grDevices::bmp(new, ...)
defer_dev_close(.local_envir)
}
Expand All @@ -56,7 +62,13 @@ with_cairo_pdf <- function(new, code, ...) {

#' @rdname devices
#' @export
local_cairo_pdf <- function(new, ..., .local_envir = parent.frame()) {
local_cairo_pdf <- function(new = NULL, ..., .local_envir = parent.frame()) {
new <- new %||%
local_tempfile(
.local_envir = .local_envir,
pattern = "withr_file",
fileext = ".pdf"
)
grDevices::cairo_pdf(new, ...)
defer_dev_close(.local_envir)
}
Expand All @@ -70,7 +82,13 @@ with_cairo_ps <- function(new, code, ...) {

#' @rdname devices
#' @export
local_cairo_ps <- function(new, ..., .local_envir = parent.frame()) {
local_cairo_ps <- function(new = NULL, ..., .local_envir = parent.frame()) {
new <- new %||%
local_tempfile(
.local_envir = .local_envir,
pattern = "withr_file",
fileext = ".ps"
)
grDevices::cairo_ps(new, ...)
defer_dev_close(.local_envir)
}
Expand All @@ -84,7 +102,13 @@ with_pdf <- function(new, code, ...) {

#' @rdname devices
#' @export
local_pdf <- function(new, ..., .local_envir = parent.frame()) {
local_pdf <- function(new = NULL, ..., .local_envir = parent.frame()) {
new <- new %||%
local_tempfile(
.local_envir = .local_envir,
pattern = "withr_file",
fileext = ".pdf"
)
grDevices::pdf(new, ...)
defer_dev_close(.local_envir)
}
Expand All @@ -98,7 +122,13 @@ with_postscript <- function(new, code, ...) {

#' @rdname devices
#' @export
local_postscript <- function(new, ..., .local_envir = parent.frame()) {
local_postscript <- function(new = NULL, ..., .local_envir = parent.frame()) {
new <- new %||%
local_tempfile(
.local_envir = .local_envir,
pattern = "withr_file",
fileext = ".ps"
)
grDevices::postscript(new, ...)
defer_dev_close(.local_envir)
}
Expand All @@ -112,7 +142,13 @@ with_svg <- function(new, code, ...) {

#' @rdname devices
#' @export
local_svg <- function(new, ..., .local_envir = parent.frame()) {
local_svg <- function(new = NULL, ..., .local_envir = parent.frame()) {
new <- new %||%
local_tempfile(
.local_envir = .local_envir,
pattern = "withr_file",
fileext = ".svg"
)
grDevices::svg(new, ...)
defer_dev_close(.local_envir)
}
Expand All @@ -126,7 +162,13 @@ with_tiff <- function(new, code, ...) {

#' @rdname devices
#' @export
local_tiff <- function(new, ..., .local_envir = parent.frame()) {
local_tiff <- function(new = NULL, ..., .local_envir = parent.frame()) {
new <- new %||%
local_tempfile(
.local_envir = .local_envir,
pattern = "withr_file",
fileext = ".tif"
)
grDevices::tiff(new, ...)
defer_dev_close(.local_envir)
}
Expand All @@ -140,7 +182,13 @@ with_xfig <- function(new, code, ...) {

#' @rdname devices
#' @export
local_xfig <- function(new, ..., .local_envir = parent.frame()) {
local_xfig <- function(new = NULL, ..., .local_envir = parent.frame()) {
new <- new %||%
local_tempfile(
.local_envir = .local_envir,
pattern = "withr_file",
fileext = ".fig"
)
grDevices::xfig(new, ...)
defer_dev_close(.local_envir)
}
Expand All @@ -154,7 +202,13 @@ with_png <- function(new, code, ...) {

#' @rdname devices
#' @export
local_png <- function(new, ..., .local_envir = parent.frame()) {
local_png <- function(new = NULL, ..., .local_envir = parent.frame()) {
new <- new %||%
local_tempfile(
.local_envir = .local_envir,
pattern = "withr_file",
fileext = ".png"
)
grDevices::png(new, ...)
defer_dev_close(.local_envir)
}
Expand All @@ -168,7 +222,13 @@ with_jpeg <- function(new, code, ...) {

#' @rdname devices
#' @export
local_jpeg <- function(new, ..., .local_envir = parent.frame()) {
local_jpeg <- function(new = NULL, ..., .local_envir = parent.frame()) {
new <- new %||%
local_tempfile(
.local_envir = .local_envir,
pattern = "withr_file",
fileext = ".jpg"
)
grDevices::jpeg(new, ...)
defer_dev_close(.local_envir)
}
Expand Down
32 changes: 16 additions & 16 deletions man/devices.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/with_collate.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/with_libpaths.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/with_temp_libpaths.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/withr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading