Skip to contents

webrarian ships ready-to-build examples. This copies one into dest (or a new temporary directory) and returns the copy's path, so that building it never writes into the installed package.

Usage

collection_example(name, dest = NULL)

Arguments

name

The example, one of "basic", "branded", "data-analysis" (prebuilt packages and a multi-file analysis), "local-package" (a local package compiled in Docker) or "mirror" (a script that builds a mirror).

dest

Directory to copy the example into. It is created if needed and must be empty if it exists, because nothing is ever overwritten. NULL (the default) copies into a new directory under tempdir().

Value

The path of the copy.

Examples

path <- collection_example("basic")
#> ✔ Copied the "basic" example to /tmp/RtmpQU25pJ/webrarian-basic-206b29361002
list.files(path)
#> [1] "README.md"      "_webrarian.yml" "analysis.R"     "data"          
#> [5] "helpers.R"     

# Build and look at the copy, loading the webR engine from its CDN so
# nothing is downloaded; the installed example is untouched
settings_set(path, "build.bundle-engine" = FALSE)
bind(path)
#> 
#> ── Building webrarian bundle ───────────────────────────────────────────────────
#> Project: "Basic example"
#> webR version: "0.6.0"
#> Output: /tmp/RtmpQU25pJ/webrarian-basic-206b29361002/_site
#> ℹ Using webR CDN engine (v0.6.0)
#> ℹ Copying collection files...
#> ℹ Including 3 files in VFS
#> ℹ Copying collection files...

#> ✔ Copying collection files... [34ms]
#> 
#> ℹ Emitting viewer + config...
#> ✔ Emitted viewer with inline config
#> ℹ Emitting viewer + config...

#> ✔ Wrote _headers
#> ℹ Emitting viewer + config...

#> ✔ Emitting viewer + config... [42ms]
#> 
#> ✔ Build complete! Output size: 1.49M (engine 0, packages 0, files 582, viewer 1.49M)
#> 
#> Preview:
#> `webrarian::reading_room("/tmp/RtmpQU25pJ/webrarian-basic-206b29361002")`
collection_files(path)$files
#> [1] "analysis.R"      "helpers.R"       "data/sample.csv"

unlink(path, recursive = TRUE)