Skip to content

Commit 65ca8a3

Browse files
authored
Deprecate build_vignettes() and clean_vignettes() (#2648)
Fixes #2488
1 parent 1c70e59 commit 65ca8a3

7 files changed

Lines changed: 64 additions & 42 deletions

File tree

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# devtools (development version)
22

33
* `build_manual()` reports more details on failure (#2586).
4+
* `build_vignettes()` and `clean_vignettes()` are now deprecated. We no longer recommend building vignettes in this way; instead use `pkgdown::build_article()` to render articles locally (#2488).
45
* `build_site()` now just calls `pkgdown::build_site()`, meaning that you will get more (informative) output by default (#2578).
56
* New `check_mac_devel()` function to check a package using the macOS builder at https://mac.r-project.org/macbuilder/submit.html (@nfrerebeau, #2507)
67
* `dev_sitrep()` now works correctly in Positron (#2618).

R/vignettes.R

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
#' Build package vignettes.
1+
#' Build package vignettes
22
#'
3-
#' Builds package vignettes using the same algorithm that `R CMD build`
4-
#' does. This means including non-Sweave vignettes, using makefiles (if
5-
#' present), and copying over extra files. The files are copied in the 'doc'
6-
#' directory and an vignette index is created in 'Meta/vignette.rds', as they
7-
#' would be in a built package. 'doc' and 'Meta' are added to
8-
#' `.Rbuildignore`, so will not be included in the built package. These
9-
#' files can be checked into version control, so they can be viewed with
10-
#' `browseVignettes()` and `vignette()` if the package has been
11-
#' loaded with `load_all()` without needing to re-build them locally.
3+
#' @description
4+
#' `r lifecycle::badge("deprecated")`
5+
#'
6+
#' `build_vignettes()` is deprecated because we no longer recommend that you
7+
#' build vignettes in this way, because it leaves build artifacts in your
8+
#' development directory. Instead, use [pkgdown::build_article()] to
9+
#' render articles locally for preview and polishing.
1210
#'
1311
#' @template devtools
1412
#' @param quiet If `TRUE`, suppresses most output. Set to `FALSE`
@@ -22,11 +20,8 @@
2220
#' @inheritParams tools::buildVignettes
2321
#' @inheritParams remotes::install_deps
2422
#' @importFrom stats update
25-
#' @keywords programming
26-
#' @seealso [clean_vignettes()] to remove the pdfs in
27-
#' \file{doc} created from vignettes
23+
#' @keywords internal
2824
#' @export
29-
#' @seealso [clean_vignettes()] to remove build tex/pdf files.
3025
build_vignettes <- function(
3126
pkg = ".",
3227
dependencies = "VignetteBuilder",
@@ -36,12 +31,13 @@ build_vignettes <- function(
3631
install = TRUE,
3732
keep_md = TRUE
3833
) {
34+
lifecycle::deprecate_warn("2.5.0", "build_vignettes()")
3935
pkg <- as.package(pkg)
4036
save_all()
4137

4238
vigns <- tools::pkgVignettes(dir = pkg$path)
4339
if (length(vigns$docs) == 0) {
44-
return()
40+
return(invisible())
4541
}
4642

4743
deps <- remotes::dev_package_deps(pkg$path, dependencies)
@@ -86,18 +82,22 @@ create_vignette_index <- function(pkg, vigns) {
8682
saveRDS(vignette_index, vignette_index_path, version = 2L)
8783
}
8884

89-
#' Clean built vignettes.
85+
#' Clean built vignettes
86+
#'
87+
#' @description
88+
#' `r lifecycle::badge("deprecated")`
9089
#'
91-
#' This uses a fairly rudimentary algorithm where any files in \file{doc}
92-
#' with a name that exists in \file{vignettes} are removed.
90+
#' `clean_vignettes()` is deprecated because [build_vignettes()] is deprecated.
9391
#'
9492
#' @template devtools
93+
#' @keywords internal
9594
#' @export
9695
clean_vignettes <- function(pkg = ".") {
96+
lifecycle::deprecate_warn("2.5.0", "clean_vignettes()")
9797
pkg <- as.package(pkg)
9898
vigns <- tools::pkgVignettes(dir = pkg$path)
99-
if (path_file(vigns$dir) != "vignettes") {
100-
return()
99+
if (length(vigns$docs) == 0 || path_file(vigns$dir) != "vignettes") {
100+
return(invisible())
101101
}
102102

103103
cli::cli_inform(c(

_pkgdown.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ reference:
1919
desc: Primary commands used when developing a package.
2020
contents:
2121
- build
22-
- starts_with("build_")
22+
- build_manual
23+
- build_rmd
24+
- build_site
2325
- starts_with("check_")
2426
- check
2527
- create
@@ -35,7 +37,6 @@ reference:
3537
- title: Utilities
3638
contents:
3739
- bash
38-
- clean_vignettes
3940
- dev_sitrep
4041
- github_pull
4142
- lint
@@ -47,9 +48,10 @@ reference:
4748
- update_packages
4849
- wd
4950
- save_all
50-
5151
- title: Deprecated functions
5252
contents:
53+
- build_vignettes
54+
- clean_vignettes
5355
- release
5456

5557
news:

man/build_vignettes.Rd

Lines changed: 7 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/clean_vignettes.Rd

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/_snaps/vignettes.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# build_vignettes() and clean_vignettes() are deprecated
2+
3+
Code
4+
build_vignettes(pkg)
5+
Condition
6+
Warning:
7+
`build_vignettes()` was deprecated in devtools 2.5.0.
8+
Code
9+
clean_vignettes(pkg)
10+
Condition
11+
Warning:
12+
`clean_vignettes()` was deprecated in devtools 2.5.0.
13+

tests/testthat/test-vignettes.R

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
test_that("Sweave vignettes copied into doc", {
2+
withr::local_options(lifecycle_verbosity = "quiet")
23
if (!pkgbuild::has_latex()) {
34
skip("pdflatex not available")
45
}
@@ -13,6 +14,7 @@ test_that("Sweave vignettes copied into doc", {
1314
})
1415

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

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

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

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

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

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

5762
suppressMessages(build_vignettes(pkg, quiet = TRUE))
5863
expect_true(all(c("/Meta/", "/doc/") %in% readLines(gitignore)))
5964
})
65+
66+
test_that("build_vignettes() and clean_vignettes() are deprecated", {
67+
pkg <- local_package_create()
68+
expect_snapshot({
69+
build_vignettes(pkg)
70+
clean_vignettes(pkg)
71+
})
72+
})

0 commit comments

Comments
 (0)