Skip to content

Commit 9459c8d

Browse files
authored
Use temporary directory for get_tutorial_info() example (#740)
1 parent cab4a72 commit 9459c8d

File tree

3 files changed

+38
-11
lines changed

3 files changed

+38
-11
lines changed

Diff for: .github/workflows/pkgdown.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ jobs:
9191
shell: Rscript {0}
9292
run: |
9393
subdir <- "${{ env.subdir }}"
94+
if (nzchar(subdir)) {
95+
Sys.setenv("PKGDOWN_DEV_MODE" = if (grepl("^v([0-9]+\\.?){3}$", subdir)) "released" else "unreleased")
96+
}
9497
pkgdown::deploy_to_branch(
9598
subdir = if (nzchar(subdir)) subdir,
96-
clean = nzchar(subdir),
97-
override = if (!nzchar(subdir)) list() else list(
98-
development = list(mode = if (grepl("^v([0-9]+\\.?){3}$", subdir)) "released" else "unreleased")
99-
)
99+
clean = nzchar(subdir)
100100
)
101101
102102
pkgdown-clean:

Diff for: R/tutorial-state.R

+21-4
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,27 @@ set_tutorial_state <- function(label, data, session = getDefaultReactiveDomain()
176176
#' correspond to the current tutorial.
177177
#'
178178
#' @examples
179-
#' tutorial_rmd <- system.file(
180-
#' "tutorials", "hello", "hello.Rmd", package = "learnr"
181-
#' )
182-
#' get_tutorial_info(tutorial_rmd)
179+
#' if (rmarkdown::pandoc_available("1.4")) {
180+
#' tutorial_rmd <- local({
181+
#' # Use a temp copy of "Hello learnr" tutorial for this example
182+
#' src <- system.file(
183+
#' "tutorials", "hello", "hello.Rmd", package = "learnr"
184+
#' )
185+
#' dest <- tempfile(fileext = ".Rmd")
186+
#' file.copy(src, dest)
187+
#' dest
188+
#' })
189+
#'
190+
#' # ---- This is the example! ------------ #
191+
#' info <- get_tutorial_info(tutorial_rmd)
192+
#' # -------------------------------------- #
193+
#'
194+
#' # clean up the temporary Rmd used in this example
195+
#' unlink(tutorial_rmd)
196+
#'
197+
#' # This is the result of the example
198+
#' info
199+
#' }
183200
#'
184201
#' @inheritParams get_tutorial_state
185202
#' @param tutorial_path Path to a tutorial `.Rmd` source file

Diff for: man/get_tutorial_info.Rd

+13-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)