Skip to content

Commit

Permalink
Add clean arg to BuildVignettes
Browse files Browse the repository at this point in the history
  • Loading branch information
jfisher-usgs committed Nov 7, 2018
1 parent 06549ef commit 36aeec3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
17 changes: 10 additions & 7 deletions R/BuildVignettes.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#' Build Package Vignettes
#'
#' Build package vignettes from their sources.
#' Build package vignettes from their sources and place in the \code{/inst/doc} folder.
#'
#' @param pkg 'character' string.
#' Package path, defaults to the working directory.
#' Package path, by default the \link[=getwd]{working directory}.
#' @param quiet 'logical' flag.
#' Whether to supress most output.
#' @param clean 'logical' flag.
#' Whether to remove all intermediate files generated by the build.
#' @param gs_quality 'character' string.
#' Quailty to use when compacting PDF files,
#' Quality of compacted PDF files,
#' see \code{\link[tools]{compactPDF}} function for details.
#'
#' @author J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center
Expand All @@ -24,22 +26,23 @@
#' }
#'

BuildVignettes <- function(pkg=".", quiet=TRUE, gs_quality=NULL) {
BuildVignettes <- function(pkg=".", quiet=TRUE, clean=TRUE, gs_quality=NULL) {

checkmate::assertFileExists(file.path(pkg, "DESCRIPTION"))
checkmate::assertFlag(quiet)
checkmate::assertFlag(clean)
if (!is.null(gs_quality))
gs_quality <- match.arg(gs_quality, c("none", "printer", "ebook", "screen"))

tools::buildVignettes(dir=pkg, quiet=quiet, tangle=TRUE)
tools::buildVignettes(dir=pkg, quiet=quiet, clean=clean, tangle=TRUE)

v <- tools::pkgVignettes(dir=pkg, output=TRUE, source=TRUE)
if (length(v) == 0) return(invisible(NULL))
out <- c(unique(unlist(v$sources, use.names=FALSE)), v$outputs)
out <- c(v$outputs, unique(unlist(v$sources, use.names=FALSE)))

doc <- file.path(pkg, "inst/doc")

dir.create(doc, showWarnings=FALSE, recursive=TRUE)
dir.create(doc, showWarnings=!quiet, recursive=TRUE)
file.copy(c(v$docs, out), doc, overwrite=TRUE)
file.remove(out)

Expand Down
12 changes: 8 additions & 4 deletions man/BuildVignettes.Rd

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

0 comments on commit 36aeec3

Please sign in to comment.