From 1066953741b0fbfd966f85c2e737e91121d8afd2 Mon Sep 17 00:00:00 2001 From: Trevor L Davis Date: Thu, 28 Mar 2024 13:07:37 -0700 Subject: [PATCH] fix: Skip 'cat_bookmarks()' examples/tests if no 'pdftk' * New `get_bookmarks_pdftools()` is not good enough for use with `set_bookmarks()` since doesn't know page numbers. Need to make sure `get_bookmarks_pdftk()` will be called in examples/tests otherwise skip. --- .github/workflows/R-CMD-check.yaml | 2 +- R/bookmarks.R | 5 ++++- man/cat_bookmarks.Rd | 5 ++++- tests/testthat/test-bookmarks.R | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index f7716e7..4d29bfc 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -29,7 +29,7 @@ jobs: R_KEEP_PKG_SOURCE: yes steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: r-lib/actions/setup-pandoc@v2 diff --git a/R/bookmarks.R b/R/bookmarks.R index 5ccbc7a..ecb0a89 100644 --- a/R/bookmarks.R +++ b/R/bookmarks.R @@ -138,7 +138,10 @@ get_bookmarks_pdftools <- function(filename, use_names = TRUE) { #' A "total_pages" attribute will be set for the theoretical total pages of #' the concatenated document represented by the concatenated bookmarks. #' @examples -#' if (supports_get_bookmarks() && supports_set_bookmarks() && require("grid", quietly = TRUE)) { +#' if (supports_get_bookmarks() && +#' supports_set_bookmarks() && +#' supports_pdftk() && +#' require("grid", quietly = TRUE)) { #' # Create two different two-page pdf files #' make_pdf <- function(f, title) { #' pdf(f, onefile = TRUE, title = title) diff --git a/man/cat_bookmarks.Rd b/man/cat_bookmarks.Rd index c607cd8..7f957dd 100644 --- a/man/cat_bookmarks.Rd +++ b/man/cat_bookmarks.Rd @@ -49,7 +49,10 @@ Useful if wanting to concatenate multiple pdf files together and would like to preserve the bookmarks information. } \examples{ -if (supports_get_bookmarks() && supports_set_bookmarks() && require("grid", quietly = TRUE)) { +if (supports_get_bookmarks() && + supports_set_bookmarks() && + supports_pdftk() && + require("grid", quietly = TRUE)) { # Create two different two-page pdf files make_pdf <- function(f, title) { pdf(f, onefile = TRUE, title = title) diff --git a/tests/testthat/test-bookmarks.R b/tests/testthat/test-bookmarks.R index f3d860e..77b6b6b 100644 --- a/tests/testthat/test-bookmarks.R +++ b/tests/testthat/test-bookmarks.R @@ -186,7 +186,7 @@ test_that("`get_count()` and `get_level()`", { }) test_that("`cat_bookmarks()` works", { - skip_if_not(supports_get_bookmarks() && supports_set_bookmarks()) + skip_if_not(supports_get_bookmarks() && supports_set_bookmarks() && supports_pdftk()) bookmarks <- data.frame(title = c("Page 1", "Page 2"), page = c(1L, 2L)) f2 <- tempfile(fileext = ".pdf")