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
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# devtools (development version)

* `build_manual()` reports more details on failure (#2586).
* `build_vignettes()` and `clean_vignettes()` are now deprecated. We no longer recommend building and checking in vignettes; instead use `pkgdown::build_article()` to render articles locally for polishing (#2488).
* New `check_mac_devel()` function to check a package using the macOS builder at https://mac.r-project.org/macbuilder/submit.html (@nfrerebeau, #2507)
* `is_loading()` is now re-exported from pkgload (#2556).
* `load_all()` now errors if called recursively, i.e. if you accidentally include a `load_all()` call in one of your R source files (#2617).
Expand Down
39 changes: 19 additions & 20 deletions R/vignettes.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#' Build package vignettes.
#' Build package vignettes
#'
#' Builds package vignettes using the same algorithm that `R CMD build`
#' does. This means including non-Sweave vignettes, using makefiles (if
#' present), and copying over extra files. The files are copied in the 'doc'
#' directory and an vignette index is created in 'Meta/vignette.rds', as they
#' would be in a built package. 'doc' and 'Meta' are added to
#' `.Rbuildignore`, so will not be included in the built package. These
#' files can be checked into version control, so they can be viewed with
#' `browseVignettes()` and `vignette()` if the package has been
#' loaded with `load_all()` without needing to re-build them locally.
#' @description
#' `r lifecycle::badge("deprecated")`
#'
#' `build_vignettes()` is deprecated because we no longer recommend that you
#' build and check in vignettes. Instead, use `pkgdown::build_article()` to
#' render articles locally for preview and polishing.
#'
#' @template devtools
#' @param quiet If `TRUE`, suppresses most output. Set to `FALSE`
Expand All @@ -22,11 +19,8 @@
#' @inheritParams tools::buildVignettes
#' @inheritParams remotes::install_deps
#' @importFrom stats update
#' @keywords programming
#' @seealso [clean_vignettes()] to remove the pdfs in
#' \file{doc} created from vignettes
#' @keywords internal
#' @export
#' @seealso [clean_vignettes()] to remove build tex/pdf files.
build_vignettes <- function(
pkg = ".",
dependencies = "VignetteBuilder",
Expand All @@ -36,12 +30,13 @@ build_vignettes <- function(
install = TRUE,
keep_md = TRUE
) {
lifecycle::deprecate_warn("2.5.0", "build_vignettes()")
pkg <- as.package(pkg)
save_all()

vigns <- tools::pkgVignettes(dir = pkg$path)
if (length(vigns$docs) == 0) {
return()
return(invisible())
}

deps <- remotes::dev_package_deps(pkg$path, dependencies)
Expand Down Expand Up @@ -86,18 +81,22 @@ create_vignette_index <- function(pkg, vigns) {
saveRDS(vignette_index, vignette_index_path, version = 2L)
}

#' Clean built vignettes.
#' Clean built vignettes
#'
#' @description
#' `r lifecycle::badge("deprecated")`
#'
#' This uses a fairly rudimentary algorithm where any files in \file{doc}
#' with a name that exists in \file{vignettes} are removed.
#' `clean_vignettes()` is deprecated because [build_vignettes()] is deprecated.
#'
#' @template devtools
#' @keywords internal
#' @export
clean_vignettes <- function(pkg = ".") {
lifecycle::deprecate_warn("2.5.0", "clean_vignettes()")
pkg <- as.package(pkg)
vigns <- tools::pkgVignettes(dir = pkg$path)
if (path_file(vigns$dir) != "vignettes") {
return()
if (length(vigns$docs) == 0 || path_file(vigns$dir) != "vignettes") {
return(invisible())
}

cli::cli_inform(c(
Expand Down
9 changes: 7 additions & 2 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ reference:
desc: Primary commands used when developing a package.
contents:
- build
- starts_with("build_")
- build_manual
- build_rmd
- build_site
- starts_with("check_")
- check
- create
Expand All @@ -36,7 +38,6 @@ reference:
- title: Utilities
contents:
- bash
- clean_vignettes
- dev_sitrep
- github_pull
- lint
Expand All @@ -48,6 +49,10 @@ reference:
- update_packages
- wd
- save_all
- title: Deprecated
contents:
- build_vignettes
- clean_vignettes

news:
releases:
Expand Down
23 changes: 7 additions & 16 deletions man/build_vignettes.Rd

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

8 changes: 5 additions & 3 deletions man/clean_vignettes.Rd

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

13 changes: 13 additions & 0 deletions tests/testthat/_snaps/vignettes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# build_vignettes() and clean_vignettes() are deprecated

Code
build_vignettes(pkg)
Condition
Warning:
`build_vignettes()` was deprecated in devtools 2.5.0.
Code
clean_vignettes(pkg)
Condition
Warning:
`clean_vignettes()` was deprecated in devtools 2.5.0.

13 changes: 13 additions & 0 deletions tests/testthat/test-vignettes.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
test_that("Sweave vignettes copied into doc", {
withr::local_options(lifecycle_verbosity = "quiet")
if (!pkgbuild::has_latex()) {
skip("pdflatex not available")
}
Expand All @@ -13,6 +14,7 @@ test_that("Sweave vignettes copied into doc", {
})

test_that("Built files are updated", {
withr::local_options(lifecycle_verbosity = "quiet")
# This test is time dependant and sometimes fails on CRAN because the systems are under heavy load.
skip_on_cran()
pkg <- local_package_copy(test_path("testMarkdownVignettes"))
Expand All @@ -29,6 +31,7 @@ test_that("Built files are updated", {
})

test_that("Rmarkdown vignettes copied into doc", {
withr::local_options(lifecycle_verbosity = "quiet")
pkg <- local_package_copy(test_path("testMarkdownVignettes"))
doc <- path(pkg, "doc")

Expand All @@ -37,6 +40,7 @@ test_that("Rmarkdown vignettes copied into doc", {
})

test_that("extra files copied and removed", {
withr::local_options(lifecycle_verbosity = "quiet")
pkg <- local_package_copy(test_path("testMarkdownVignettes"))
writeLines("a <- 1", path(pkg, "vignettes", "a.R"))

Expand All @@ -51,9 +55,18 @@ test_that("extra files copied and removed", {
})

test_that(".gitignore updated when building vignettes", {
withr::local_options(lifecycle_verbosity = "quiet")
pkg <- local_package_copy(test_path("testMarkdownVignettes"))
gitignore <- path(pkg, ".gitignore")

suppressMessages(build_vignettes(pkg, quiet = TRUE))
expect_true(all(c("/Meta/", "/doc/") %in% readLines(gitignore)))
})

test_that("build_vignettes() and clean_vignettes() are deprecated", {
pkg <- local_package_create()
expect_snapshot({
build_vignettes(pkg)
clean_vignettes(pkg)
})
})
Loading