Skip to content

Commit

Permalink
Add quiet argument to document
Browse files Browse the repository at this point in the history
Fixes #1986
  • Loading branch information
jimhester committed Aug 30, 2019
1 parent 1c270c8 commit 4a11f28
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# devtools (development version)

* `document()` gains a `quiet` parameter, to silence output and `check()` now
passes its quiet argument to it (#1986).

* Add the DT package as a dependency, so that `test_coverage()` and
`test_coverage_file()` work without having to install additional packages
(#2085).
Expand Down
2 changes: 1 addition & 1 deletion R/check.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ check <- function(pkg = ".",
document <- !is.null(pkg$roxygennote)
}
if (document) {
document(pkg)
document(pkg, quiet = quiet)
}

if (!quiet) {
Expand Down
2 changes: 1 addition & 1 deletion R/doctor.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
NULL

.rstudio_release <- function() {
url <- "http://s3.amazonaws.com/rstudio-server/current.ver"
url <- "http://s3.amazonaws.com/rstudio-desktop/current.ver"
res <- readLines(url, warn = FALSE)
if (length(res) != 1) {
return(0)
Expand Down
21 changes: 17 additions & 4 deletions R/document.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,35 @@
#' @param pkg package description, can be path or package name. See
#' [as.package()] for more information
#' @inheritParams roxygen2::roxygenise
#' @param quiet if `TRUE` suppresses output from this function.
#' @seealso [roxygen2::roxygenize()],
#' `browseVignettes("roxygen2")`
#' @export
document <- function(pkg = ".", roclets = NULL) {
document <- function(pkg = ".", roclets = NULL, quiet = FALSE) {
pkg <- as.package(pkg)
message("Updating ", pkg$package, " documentation")
if (!isTRUE(quiet)) {
message("Updating ", pkg$package, " documentation")
}

save_all()

if (pkg$package == "roxygen2") {
# roxygen2 crashes if it reloads itself
load_all(pkg$path, quiet = TRUE)
load_all(pkg$path, quiet = quiet)
load_code <- function(path) asNamespace("roxygen2")
} else {
load_code <- roxygen2::env_package
load_code <- function(path) {
pkgload::load_all(path, compile = FALSE, helpers = FALSE, attach_testthat = FALSE, quiet = quiet)$env
}
}

if (quiet) {
output <- tempfile()
on.exit(unlink(output))

withr::local_output_sink(output)
}

withr::with_envvar(r_env_vars(),
roxygen2::roxygenise(pkg$path, roclets, load_code = load_code)
)
Expand Down
4 changes: 3 additions & 1 deletion man/document.Rd

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

0 comments on commit 4a11f28

Please # to comment.