Skip to content

Commit

Permalink
Added save_all() helper function for saving all docs in IDE session.
Browse files Browse the repository at this point in the history
  • Loading branch information
AmundsenJunior committed Sep 7, 2018
1 parent 1793845 commit 92f8372
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 24 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
@@ -1,5 +1,7 @@
# devtools 1.13.3.9000

* `save_all()` helper function wraps `rstudioapi::documentSaveAll()` calls (#1850, @amundsenjunior).

* `check()` now allows users to run without `--timings` (#1655)

* devtools now depends on roxygen2 6.1.0: this considerably simplifies
Expand Down
4 changes: 1 addition & 3 deletions R/build-readme.R
Expand Up @@ -10,9 +10,7 @@
build_readme <- function(path = ".", quiet = TRUE, ...) {
check_suggested("rmarkdown")

if (rstudioapi::hasFun("documentSaveAll")) {
rstudioapi::documentSaveAll()
}
save_all()

pkg <- as.package(path)

Expand Down
4 changes: 1 addition & 3 deletions R/build-site.R
Expand Up @@ -12,9 +12,7 @@
build_site <- function(path = ".", quiet = TRUE, ...) {
check_suggested("pkgdown")

if (rstudioapi::hasFun("documentSaveAll")) {
rstudioapi::documentSaveAll()
}
save_all()

pkg <- as.package(path)

Expand Down
4 changes: 1 addition & 3 deletions R/check.r
Expand Up @@ -72,9 +72,7 @@ check <- function(pkg = ".",
pkg <- as.package(pkg)
withr::local_options(list(warn = 1))

if (rstudioapi::hasFun("documentSaveAll")) {
rstudioapi::documentSaveAll()
}
save_all()

if (!missing(cleanup)) {
warning("`cleanup` is deprecated", call. = FALSE)
Expand Down
4 changes: 1 addition & 3 deletions R/document.r
Expand Up @@ -16,9 +16,7 @@ document <- function(pkg = ".", roclets = NULL) {
pkg <- as.package(pkg)
message("Updating ", pkg$package, " documentation")

if (rstudioapi::hasFun("documentSaveAll")) {
rstudioapi::documentSaveAll()
}
save_all()

withr::with_envvar(r_env_vars(), roxygen2::roxygenise(pkg$path, roclets))

Expand Down
4 changes: 1 addition & 3 deletions R/pkgbuild.R
Expand Up @@ -3,9 +3,7 @@
#' @export
build <- function(path = ".", dest_path = NULL, binary = FALSE, vignettes = TRUE,
manual = FALSE, args = NULL, quiet = FALSE, ...) {
if (rstudioapi::hasFun("documentSaveAll")) {
rstudioapi::documentSaveAll()
}
save_all()
pkgbuild::build(path = path, dest_path = dest_path, binary = binary,
vignettes = vignettes, manual = manual, args = args, quiet = quiet, ...)
}
Expand Down
4 changes: 1 addition & 3 deletions R/pkgload.R
Expand Up @@ -3,9 +3,7 @@
#' @export
load_all <- function(path = ".", reset = TRUE, recompile = FALSE,
export_all = TRUE, helpers = TRUE, quiet = FALSE, ...) {
if (rstudioapi::hasFun("documentSaveAll")) {
rstudioapi::documentSaveAll()
}
save_all()

pkgload::load_all(path = path, reset = reset, recompile = recompile,
export_all = export_all, helpers = helpers, quiet = quiet, ...)
Expand Down
13 changes: 13 additions & 0 deletions R/save-all.R
@@ -0,0 +1,13 @@
#' Save all documents in an active IDE session.
#'
#' Helper function wrapping IDE-specific calls to save all documents in the
#' active session. In this form, callers of \code{save_all()} don't need to
#' execute any IDE-specific code. This function can be extened to include
#' other IDE implementations of their equivalent
#' \code{rstudioapi::documentSaveAll()} methods.
#' @return NULL
save_all <- function() {
if (rstudioapi::hasFun("documentSaveAll")) {
rstudioapi::documentSaveAll()
}
}
8 changes: 2 additions & 6 deletions R/test.r
Expand Up @@ -22,9 +22,7 @@
test <- function(pkg = ".", filter = NULL, ...) {
check_suggested("testthat")

if (rstudioapi::hasFun("documentSaveAll")) {
rstudioapi::documentSaveAll()
}
save_all()

pkg <- as.package(pkg)

Expand Down Expand Up @@ -83,9 +81,7 @@ test_coverage <- function(pkg = ".", show_report = interactive(), ...) {

check_suggested("covr")

if (rstudioapi::hasFun("documentSaveAll")) {
rstudioapi::documentSaveAll()
}
save_all()

withr::with_envvar(r_env_vars(),
coverage <- covr::package_coverage(pkg$path, ...)
Expand Down
15 changes: 15 additions & 0 deletions man/save_all.Rd

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

0 comments on commit 92f8372

Please sign in to comment.