Title: | Create and Curate Carpentries Lessons |
---|---|
Description: | We provide tools to build a Carpentries-themed lesson repository into an accessible standalone static website. These include local tools and those designed to be used in a continuous integration context so that all the lesson author needs to focus on is writing the content of the actual lesson. |
Authors: | Robert Davey [aut, cre] , Erin Becker [aut] , Zhian N. Kamvar [aut] , Julien Colomb [ctb] , Ben Companjen [ctb] , Toby Hodges [ctb], François Michonneau [ctb], Kelly Barnes [ctb], Hugo Gruson [ctb], Milan Malfait [ctb] , Joel H. Nitta [aut, trl] , Yanina Bellini Saibene [ctb, trl] , Martin Raden [ctb, trl] , Matthew Armstrong [ctb] |
Maintainer: | Robert Davey <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.16.10 |
Built: | 2024-11-11 15:20:57 UTC |
Source: | https://github.com/carpentries/sandpaper |
This function will build a handout and save it to files/code-handout.R
in your lesson website. This will build with your website if you enable it
with options(sandpaper.handout = TRUE)
or if you want to specify a path,
you can use options(sandpaper.handout = "/path/to/handout.R")
to save the
handout to a specific path.
build_handout(path = ".", out = NULL)
build_handout(path = ".", out = NULL)
path |
the path to the lesson. Defaults to current working directory |
out |
the path to the handout document. When this is |
This function orchestrates rendering generated lesson content and applying the theme for the HTML site.
build_lesson( path = ".", rebuild = FALSE, quiet = !interactive(), preview = TRUE, override = list() )
build_lesson( path = ".", rebuild = FALSE, quiet = !interactive(), preview = TRUE, override = list() )
path |
the path to your repository (defaults to your current working directory) |
rebuild |
if |
quiet |
when |
preview |
if |
override |
options to override (e.g. building to alternative paths). This is used internally and will likely be changed. |
A Carpentries Workbench lesson is comprised of a set of markdown files and folders:
+-- config.yaml +-- index.md +-- episodes | +-- data | +-- fig | +-- files | \-- introduction.Rmd +-- instructors | \-- instructor-notes.md +-- learners | \-- setup.md +-- profiles | \-- learner-profiles.md +-- links.md +-- site \-- [...] +-- renv | \-- [...] +-- CODE_OF_CONDUCT.md +-- CONTRIBUTING.md +-- LICENSE.md \-- README.md
TRUE
if it was successful, a character vector of issues if it was
unsuccessful.
serve()
: an interactive way to build and edit lesson content.
tmp <- tempfile() create_lesson(tmp, open = FALSE, rmd = FALSE) create_episode("first-script", path = tmp, open = FALSE) check_lesson(tmp) build_lesson(tmp)
tmp <- tempfile() create_lesson(tmp, open = FALSE, rmd = FALSE) create_episode("first-script", path = tmp, open = FALSE) check_lesson(tmp) build_lesson(tmp)
These functions allow you to create an episode that will be added to the schedule.
create_episode( title, ext = "Rmd", make_prefix = FALSE, add = TRUE, path = ".", open = rlang::is_interactive() ) create_episode_md( title, make_prefix = FALSE, add = TRUE, path = ".", open = rlang::is_interactive() ) create_episode_rmd( title, make_prefix = FALSE, add = TRUE, path = ".", open = rlang::is_interactive() ) draft_episode_md( title, make_prefix = FALSE, path = ".", open = rlang::is_interactive() ) draft_episode_rmd( title, make_prefix = FALSE, path = ".", open = rlang::is_interactive() )
create_episode( title, ext = "Rmd", make_prefix = FALSE, add = TRUE, path = ".", open = rlang::is_interactive() ) create_episode_md( title, make_prefix = FALSE, add = TRUE, path = ".", open = rlang::is_interactive() ) create_episode_rmd( title, make_prefix = FALSE, add = TRUE, path = ".", open = rlang::is_interactive() ) draft_episode_md( title, make_prefix = FALSE, path = ".", open = rlang::is_interactive() ) draft_episode_rmd( title, make_prefix = FALSE, path = ".", open = rlang::is_interactive() )
title |
the title of the episode |
ext |
a character. If |
make_prefix |
a logical. When |
add |
(logical or numeric) If numeric, it represents the position the
episode should be added. If |
path |
the path to the |
open |
if interactive, the episode will open in a new editor window. |
tmp <- tempfile() create_lesson(tmp, open = FALSE, rmd = FALSE) create_episode_md("getting-started", path = tmp)
tmp <- tempfile() create_lesson(tmp, open = FALSE, rmd = FALSE) create_episode_md("getting-started", path = tmp)
This will create a boilerplate directory structure for a Carpentries lesson and initialize a git repository.
create_lesson( path, name = fs::path_file(path), rmd = TRUE, rstudio = rstudioapi::isAvailable(), open = rlang::is_interactive() )
create_lesson( path, name = fs::path_file(path), rmd = TRUE, rstudio = rstudioapi::isAvailable(), open = rlang::is_interactive() )
path |
the path to the new lesson folder |
name |
the name of the lesson. If not provided, the folder name will be used. |
rmd |
logical indicator if the lesson should use R Markdown ( |
rstudio |
create an RStudio project (defaults to if RStudio exits) |
open |
if interactive, the lesson will open in a new editor window. |
the path to the new lesson
tmp <- tempfile() on.exit(unlink(tmp)) lsn <- create_lesson(tmp, name = "This Lesson", open = FALSE) lsn
tmp <- tempfile() on.exit(unlink(tmp)) lsn <- create_lesson(tmp, name = "This Lesson", open = FALSE) lsn
Get the configuration parameters for the lesson
get_config(path = ".")
get_config(path = ".")
path |
path to the lesson |
a yaml list
tmp <- tempfile() create_lesson(tmp, open = FALSE, rmd = FALSE) get_config(tmp)
tmp <- tempfile() create_lesson(tmp, open = FALSE, rmd = FALSE) get_config(tmp)
By default, {sandpaper}
will use the files in alphabetical order as they are
presented in the folders, however, it is strongly for authors to specify
the order of the files in their lessons, so that it's easy to rearrange or
add, split, or rearrange files.
get_drafts( path, folder = NULL, message = getOption("sandpaper.show_draft", TRUE) )
get_drafts( path, folder = NULL, message = getOption("sandpaper.show_draft", TRUE) )
path |
path to the the sandpaper lesson |
folder |
the specific folder for which to list the draft files. Defaults
to |
message |
if |
This mechanism also allows authors to work on files in a draft form without them being published. This function will list and show the files in draft for automation and audit.
a vector of paths to files in draft and a message (if specified)
This fuction will extract the resources that exist and are listed in the config file.
get_dropdown(path = ".", folder, trim = TRUE) get_episodes(path = ".", trim = TRUE) get_learners(path = ".", trim = TRUE) get_instructors(path = ".", trim = TRUE) get_profiles(path = ".", trim = TRUE)
get_dropdown(path = ".", folder, trim = TRUE) get_episodes(path = ".", trim = TRUE) get_learners(path = ".", trim = TRUE) get_instructors(path = ".", trim = TRUE) get_profiles(path = ".", trim = TRUE)
path |
the path to the lesson, defaults to the current working directory |
folder |
the folder to extract fromt he dropdown menues |
trim |
if |
a character vector of episodes in order of presentation
tmp <- tempfile() create_lesson(tmp, open = FALSE, rmd = FALSE) get_episodes(tmp) get_learners(tmp) # information for learners
tmp <- tempfile() create_lesson(tmp, open = FALSE, rmd = FALSE) get_episodes(tmp) get_learners(tmp) # information for learners
{sandpaper}
Show a list of languages known by {sandpaper}
known_languages()
known_languages()
The known languages are translations of menu and navigational
elements that exist in {sandpaper}
. If these elements have not been
translated for a given language and you would like to add translations for
them, please consult vignette("translations", package = "sandpaper")
for
details of how to do so in the source code for {sandpaper}
.
#> - en #> - es #> - fr #> - ja #> - uk
a character vector of language codes known by {sandpaper}
vignette("translations", package = "sandpaper")
for an overview
of providing translations.
known_languages()
known_languages()
A customized provisioner for Carpentries Lessons based on renv that will install and maintain the requirements for the lesson while respecting user environments. This setup leads to several advantages:
reliable setup: the version of the lesson built on the carpentries website will be the same as what you build on your computer because the packages will be identical
environmentally friendly: The lesson dependencies are NOT stored in your default R library and they will not alter your R environment.
transparent: any additions or deletions to the cache will be recorded in the lockfile, which is tracked by git.
The functions that control this cache are the following:
manage_deps()
: Creates and updates the dependencies in your lesson.
If no lockfile exists in your lesson, this will create one for you.
update_cache()
: fetches updates for the dependencies and applies them
to your cache and lockfile.
This is a wrapper around renv::record()
, which helps you record a package
or set of packages in your lockfile. It can be useful when you want to
upgrade or downgrade a specific package.
manage_deps( path = ".", profile = "lesson-requirements", snapshot = TRUE, quiet = FALSE ) update_cache( path = ".", profile = "lesson-requirements", prompt = interactive(), quiet = !prompt, snapshot = TRUE ) pin_version(records = NULL, profile = "lesson-requirements", path = ".")
manage_deps( path = ".", profile = "lesson-requirements", snapshot = TRUE, quiet = FALSE ) update_cache( path = ".", profile = "lesson-requirements", prompt = interactive(), quiet = !prompt, snapshot = TRUE ) pin_version(records = NULL, profile = "lesson-requirements", path = ".")
path |
path to your lesson. Defaults to the current working directory. |
profile |
default to the profile for the lesson. Defaults to
|
snapshot |
if |
quiet |
if |
prompt |
if |
records |
a character vector or list of packages/resources to include
in the lockfile. The most common way to do this is to use the
|
The renv package provides a very useful interface to bring one aspect of reproducibility to R projects. Because people working on Carpentries lessons are also working academics and will likely have projects on their computer where the package versions are necessary for their work, it's important that those environments are respected.
Our flavor of {renv}
applies a package cache explicitly to the content of
the lesson, but does not impose itself as the default {renv}
environment.
This provisioner will do the following steps:
check for consent to use the package cache via use_package_cache()
and prompt for it if needed
check if the profile has been created and create it if needed via
renv::init()
populate the cache with packages needed from the user's system and
download any that are missing via renv::hydrate()
. This includes all
new packages that have been added to the lesson.
If there is a lockfile already present, make sure the packages in the
cache are aligned with the lockfile (downloading sources if needed) via
renv::restore()
.
Record the state of the cache in a lockfile tracked by git. This will
include adding new packages and removing old packages. renv::snapshot()
When the lockfile changes, you will see it in git and have the power to either commit or restore those changes.
if snapshot = TRUE
, a nested list representing the lockfile will be
returned.
the contents of the lockfile, invisibly
use_package_cache()
and no_package_cache()
for turning on and
off the package cache, respectively.
If you need to move a single episode, this function gives you a programmatic or interactive interface to accomplishing this task, whether you need to add and episode, draft, or remove an episode from the schedule.
move_episode(ep = NULL, position = NULL, write = FALSE, path = ".")
move_episode(ep = NULL, position = NULL, write = FALSE, path = ".")
ep |
the name of a draft episode or the name/number of a published episode to move. |
position |
the position in the schedule to move the episode. Valid positions are from 0 to the number of episodes (+1 for drafts). A value of 0 indicates that the episode should be removed from the schedule. |
write |
defaults to |
path |
the path to the lesson (defaults to the current working directory) |
create_episode()
, set_episodes()
, get_drafts()
, get_episodes()
if (interactive() || Sys.getenv("CI") != "") { tmp <- tempfile() create_lesson(tmp) create_episode_md("getting-started", path = tmp, open = FALSE) create_episode_rmd("plotting", path = tmp, open = FALSE) create_episode_md("experimental", path = tmp, add = FALSE, open = FALSE) set_episodes(tmp, c("getting-started.md", "introduction.Rmd", "plotting.Rmd"), write = TRUE) # Default episode order is alphabetical, we can use this to nudge episodes get_episodes(tmp) move_episode("introduction.Rmd", 1L, path = tmp) # by default, it shows you the change move_episode("introduction.Rmd", 1L, write = TRUE, path = tmp) # write the results get_episodes(tmp) # Add episodes from the drafts get_drafts(tmp) move_episode("experimental.md", 2L, path = tmp) # view where it will live move_episode("experimental.md", 2L, write = TRUE, path = tmp) get_episodes(tmp) # Unpublish episodes by setting position to zero move_episode("experimental.md", 0L, path = tmp) # view the results move_episode("experimental.md", 0L, write = TRUE, path = tmp) get_episodes(tmp) # Interactively select the position where the episode should go by omitting # the position argument if (interactive()) { move_episode("experimental.md", path = tmp) } }
if (interactive() || Sys.getenv("CI") != "") { tmp <- tempfile() create_lesson(tmp) create_episode_md("getting-started", path = tmp, open = FALSE) create_episode_rmd("plotting", path = tmp, open = FALSE) create_episode_md("experimental", path = tmp, add = FALSE, open = FALSE) set_episodes(tmp, c("getting-started.md", "introduction.Rmd", "plotting.Rmd"), write = TRUE) # Default episode order is alphabetical, we can use this to nudge episodes get_episodes(tmp) move_episode("introduction.Rmd", 1L, path = tmp) # by default, it shows you the change move_episode("introduction.Rmd", 1L, write = TRUE, path = tmp) # write the results get_episodes(tmp) # Add episodes from the drafts get_drafts(tmp) move_episode("experimental.md", 2L, path = tmp) # view where it will live move_episode("experimental.md", 2L, write = TRUE, path = tmp) get_episodes(tmp) # Unpublish episodes by setting position to zero move_episode("experimental.md", 0L, path = tmp) # view the results move_episode("experimental.md", 0L, write = TRUE, path = tmp) get_episodes(tmp) # Interactively select the position where the episode should go by omitting # the position argument if (interactive()) { move_episode("experimental.md", path = tmp) } }
Clear the schedule in the lesson
reset_episodes(path = ".")
reset_episodes(path = ".")
path |
path to the lesson |
NULL, invisibly
tmp <- tempfile() create_lesson(tmp, open = FALSE, rmd = FALSE) get_episodes(tmp) # produces warning set_episodes(tmp, get_episodes(tmp), write = TRUE) get_episodes(tmp) # no warning reset_episodes(tmp) get_episodes(tmp) # produces warning again because there is no schedule
tmp <- tempfile() create_lesson(tmp, open = FALSE, rmd = FALSE) get_episodes(tmp) # produces warning set_episodes(tmp, get_episodes(tmp), write = TRUE) get_episodes(tmp) # no warning reset_episodes(tmp) get_episodes(tmp) # produces warning again because there is no schedule
Use this if you want to rebuild your site from scratch.
reset_site(path = ".")
reset_site(path = ".")
path |
the path to the site |
tmp <- tempfile() create_lesson(tmp, open = FALSE, rmd = FALSE) build_lesson(tmp, preview = FALSE) dir(file.path(tmp, "site")) reset_site(tmp) dir(file.path(tmp, "site"))
tmp <- tempfile() create_lesson(tmp, open = FALSE, rmd = FALSE) build_lesson(tmp, preview = FALSE) dir(file.path(tmp, "site")) reset_site(tmp) dir(file.path(tmp, "site"))
this is some documentation about options
option("sandpaper.show_draft" = TRUE) option("sandpaper.links" = NULL) option("sandpaper.use_renv" = FALSE) option("sandpaper.package_cache_trigger" = FALSE) option("sandpaper.test_fixture" = NULL)
As of 2022-02-22, there are several options that are used in sandpaper that may be manipulated by the user. This set may change in the future, but here are the description of these options and how they are set on startup:
Default: TRUE
This is for user messages. If TRUE
, a message about
episodes in draft status (i.e. episodes that are in the folder, but not in
the schedule) will be printed with get_drafts()
. Setting this option to
FALSE
will turn off this feature.
Default: NULL
This option provides a way to override the default place
for links in your sandpaper lesson. If it is NULL and there is a file called
links.md
at the top of the repository, this will be appended to the bottom
of each page before it is rendered to HTML.
Default: variable This option should not be modified by the user. It
determines if {renv}
should be used locally for R-based lessons. It is set
by use_package_cache()
and unset by no_package_cache()
. If a local user
has never consented to using {renv}
previously, then it defaults to FALSE
,
but if {renv}
has previously been used, it will be TRUE
.
Default: FALSE locally/TRUE on GitHub this tells R Markdown lessons to
rebuild everything if the {renv}
lockfile changes.
Default: NULL This is ONLY for internal use for testing interactive
components non-interactively and for setting {renv}
to behave correctly while
testing.
This function will serve your lesson and it will auto-update whenever you save a file.
serve(path = ".", quiet = !interactive(), ...)
serve(path = ".", quiet = !interactive(), ...)
path |
the path to your lesson. Defaults to the current path. |
quiet |
if |
... |
options passed on to |
sandpaper::serve()
is an entry point to working on any lesson using The
Carpentries Workbench. When you run this function interactively, a preview
window will open either in RStudio or your browser with an address like
localhost:4321
(note the number will likely be different). When you make
changes to files in your lesson, this preview will update automatically.
When you are done with the preview, you can run servr::daemon_stop()
.
You can use this on the command line if you do not use RStudio or another IDE that acts as a web browser. To run this on the command line, use:
R -e 'sandpaper::serve()'
Note that unlike an interactive session, progress messages are not printed
(except for the accessibility checks) and the browser window will not
automatically launch. You can have these messages print to screen with the
quiet = FALSE
argument. In addition, If you want to specify a port and
host for this function, you can do so using the port and host arguments:
R -e 'sandpaper::serve(quiet = FALSE, host = "127.0.0.1", port = "3435")'
the output of servr::httw()
, invisibly. This is mainly used for its
side-effect
build_lesson()
, render the lesson once, locally.
if (FALSE) { # create an example lesson tmp <- tempfile() create_lesson(tmp, open = FALSE) # open the episode for editing file.edit(fs::path(tmp, "episodes", "01-introduction.Rmd")) # serve the lesson and begin editing the file. Watch how the file will # auto-update whenever you save it. sandpaper::serve() # # to stop the server, run servr::daemon_stop() # # If you want to use a different port, you can specify it directly sandpaper::serve(host = "127.0.0.1", port = "3435") }
if (FALSE) { # create an example lesson tmp <- tempfile() create_lesson(tmp, open = FALSE) # open the episode for editing file.edit(fs::path(tmp, "episodes", "01-introduction.Rmd")) # serve the lesson and begin editing the file. Watch how the file will # auto-update whenever you save it. sandpaper::serve() # # to stop the server, run servr::daemon_stop() # # If you want to use a different port, you can specify it directly sandpaper::serve(host = "127.0.0.1", port = "3435") }
Set individual keys in a configuration file
set_config(pairs = NULL, create = FALSE, path = ".", write = FALSE)
set_config(pairs = NULL, create = FALSE, path = ".", write = FALSE)
pairs |
a named list or character vector with keys as the names and the new values as the contents |
create |
if |
path |
path to the lesson. Defaults to the current directory. |
write |
if |
This function deals strictly with keypairs in the yaml. For lists, see
set_dropdown()
.
When you create a new lesson in sandpaper, there are a set of default keypairs that are pre-filled. To make sure contact information and links in the footer are accurate, please modify these values.
carpentry [character]
one of cp, dc, swc, lab, incubator
title [character]
the lesson title (e.g. 'Introduction to R for Plant Pathologists'
created [character]
Date in ISO 8601 format (e.g. '2021-02-09'
)
keywords [character]
comma-separated list (e.g 'static site, R, tidyverse'
)
life_cycle [character]
one of pre-alpha, alpha, beta, stable
license [character]
a license for the lesson (e.g. 'CC-BY 4.0'
)
source [character]
the source repository URL
branch [character]
the default branch (e.g. 'main'
)
contact [character]
an email address of who to contact for more
information about the lesson
The following keypairs are known by sandpaper, but are optional:
lang [character]
the language code
that matches the language of the lesson content. This defaults to "en"
,
but can be any language code (e.g. "ja" specifying Japanese) or
combination language code and country code
(e.g. "pt_BR" specifies Pourtugese used in Brazil). For more information
on how this is used, see the Locale Names section of the gettext manual
url [character]
custom URL if you are deploying to a URL that is not
the default github pages io domain.
fail_on_error [boolean]
for R Markdown lessons; fail the build if any
chunks produce an error. Use #| error: true
in chunk options to allow the
error to be displayed
workbench-beta [boolean]
if truthy, this displays a banner on the
site that indicates the site is in the workbench beta phase.
overview [boolean]
All lessons must have episodes with the exception
of overview lessons. To indicate that your lesson serves as an overview for
other lessons, use overview: true
handout [boolean]
or [character]
This option instructs {sandpaper}
to create a handout of all RMarkdown files via {pegboard}
, which uses
knitr::purl()
in the background after removing everything but the
challenges (without solutions) and any code blocks where purl = TRUE
. The
default path for the handout is files/code-handout.R
As the workbench becomes more developed, some of these optional keys may disappear.
To use a specific version of sandpaper or varnish locally, you would install
them using remotes::install_github("carpentries/sandpaper@VERSION")
syntax,
but to provision these versions on GitHub, you can provision these in the
config.yaml
file:
sandpaper [character]
github string or version number of sandpaper
version to use
varnish [character]
github string or version number of varnish
version to use
pegboard [character]
github string or version number of pegboard
version to use
For example, if you had forked your own version of varnish to modify the colourscheme, you could use:
varnish: MYACCOUNT/varnish
If there is a specific branch of sandpaper or varnish that is being tested,
and you want to test it on your lesson temporarily, you could use the @
symbol to refer to the specific branch or commit to use:
sandpaper: carpentries/sandpaper@BRANCH-NAME varnish: carpentries/varnish@BRANCH-name
if (FALSE) { tmp <- tempfile() create_lesson(tmp, "test lesson", open = FALSE, rmd = FALSE) # Change the title and License (default vars) set_config(c(title = "Absolutely Free Lesson", license = "CC0"), path = tmp, write = TRUE ) # add the URL and workbench-beta indicator set_config(list("workbench-beta" = TRUE, url = "https://example.com/"), path = tmp, create = TRUE, write = TRUE ) }
if (FALSE) { tmp <- tempfile() create_lesson(tmp, "test lesson", open = FALSE, rmd = FALSE) # Change the title and License (default vars) set_config(c(title = "Absolutely Free Lesson", license = "CC0"), path = tmp, write = TRUE ) # add the URL and workbench-beta indicator set_config(list("workbench-beta" = TRUE, url = "https://example.com/"), path = tmp, create = TRUE, write = TRUE ) }
Set the order of items in a dropdown menu
set_dropdown(path = ".", order = NULL, write = FALSE, folder) set_episodes(path = ".", order = NULL, write = FALSE) set_learners(path = ".", order = NULL, write = FALSE) set_instructors(path = ".", order = NULL, write = FALSE) set_profiles(path = ".", order = NULL, write = FALSE)
set_dropdown(path = ".", order = NULL, write = FALSE, folder) set_episodes(path = ".", order = NULL, write = FALSE) set_learners(path = ".", order = NULL, write = FALSE) set_instructors(path = ".", order = NULL, write = FALSE) set_profiles(path = ".", order = NULL, write = FALSE)
path |
path to the lesson. Defaults to the current directory. |
order |
the files in the order presented (with extension) |
write |
if |
folder |
one of four folders that sandpaper recognises where the files
listed in |
tmp <- tempfile() create_lesson(tmp, "test lesson", open = FALSE, rmd = FALSE) # Change the title and License set_config(c(title = "Absolutely Free Lesson", license = "CC0"), path = tmp, write = TRUE ) create_episode("using-R", path = tmp, open = FALSE) print(sched <- get_episodes(tmp)) # reverse the schedule set_episodes(tmp, order = rev(sched)) # write it set_episodes(tmp, order = rev(sched), write = TRUE) # see it get_episodes(tmp)
tmp <- tempfile() create_lesson(tmp, "test lesson", open = FALSE, rmd = FALSE) # Change the title and License set_config(c(title = "Absolutely Free Lesson", license = "CC0"), path = tmp, write = TRUE ) create_episode("using-R", path = tmp, open = FALSE) print(sched <- get_episodes(tmp)) # reverse the schedule set_episodes(tmp, order = rev(sched)) # write it set_episodes(tmp, order = rev(sched), write = TRUE) # see it get_episodes(tmp)
Episode order for Carpentries lessons originally used a strategy of prefixing files by a two-digit number to force a specific order by filename. This function will strip these numbers from the filename and set the schedule according to the original order.
strip_prefix(path = ".", write = FALSE)
strip_prefix(path = ".", write = FALSE)
path |
the path to the lesson (defaults to the current working directory) |
write |
defaults to |
when write = TRUE
, the modified list of episodes. When
write = FALSE
, the modified call is returned.
git will recognise this as deleting a file and then adding a new file
in the stage. If you run git add
, it should recognise that it is a rename.
create_episode()
for creating new episodes, move_episode()
for
moving individual episodes around.
if (FALSE) { strip_prefix() # test if the function is doing what you want it to do strip_prefix(write = TRUE) # rewrite the episode names }
if (FALSE) { strip_prefix() # test if the function is doing what you want it to do strip_prefix(write = TRUE) # rewrite the episode names }
This function copies and updates the workflows to run {sandpaper}
.
update_github_workflows( path = ".", files = "", overwrite = TRUE, clean = "*.yaml", quiet = FALSE )
update_github_workflows( path = ".", files = "", overwrite = TRUE, clean = "*.yaml", quiet = FALSE )
path |
path to the current lesson. |
files |
the files to include in the update. Defaults to an empty string, which will update all files |
overwrite |
if |
clean |
glob of files to be cleaned before writing. Defaults to
|
quiet |
if |
the paths to the new files.
Update the local version of the carpentries style
update_varnish(version = NULL, ...)
update_varnish(version = NULL, ...)
version |
if NULL, update the latest version, otherwise, this can be a version string to identify the specific version to use. |
... |
arguments passed on to |
NULL, invisibly
this requires an internet connection
These functions explicitly gives sandpaper permission to use renv to create a package cache for this and future lessons. There are two states that you can use:
use_package_cache()
: Gives explicit permission to set up and use the
package cache with your lesson.
no_package_cache()
: Temporarily suspends permission to use the package
cache with your lesson, regardless if it was previously given.
Once you have a package cache defined, you can use changes in the lockfile to trigger rebuilds of the lesson. To do this, you can use:
package_cache_trigger(TRUE)
The above function is best used in conjunction with update_cache()
use_package_cache(prompt = interactive(), quiet = !prompt) no_package_cache() package_cache_trigger(rebuild = NULL)
use_package_cache(prompt = interactive(), quiet = !prompt) no_package_cache() package_cache_trigger(rebuild = NULL)
prompt |
if |
quiet |
if |
rebuild |
The new value of the |
By default, sandpaper will happily build your lesson using the packages available in your default R library, but this can be undesirable for a couple of reasons:
You may have a different version of a lesson package that is used on the lesson website, which may result in strange errors, warnings, or incorrect output.
You might be very cautious about updating any components of your current R infrastructure because your work depends on you having the correct package versions installed.
To alleviate these concerns, sandpaper uses the renv package to generate a lesson-specific library that has package versions pinned until the lesson authors choose to update them. This is designed to be minimally-invasive, using the packages you already have and downloading from external repositories only when necessary.
If you have used renv in the past, then there is no need to give consent to use the cache.
To turn off the feature you can use no_package_cache()
. sandpaper
will respect this option when building your lesson and will use your global
library instead.
You can set options(sandpaper.use_renv = FALSE)
before loading {sandpaper}
.
nothing. this is used for its side-effect
the value of getOption("sandpaper.package_cache_trigger")
or
FALSE
, if it is unset.
manage_deps()
and update_cache()
for managing the requirements
inside the package cache.
if (!getOption("sandpaper.use_renv") && interactive()) { # The first time you set up `{renv}`, you will need permission use_package_cache(prompt = TRUE) # The package cache trigger is FALSE, by default default <- package_cache_trigger() # You can set this to `TRUE` when you update packages with `update_cache()` package_cache_trigger(TRUE) # set the trigger back to its former state package_cache_trigger(default) } if (getOption("sandpaper.use_renv") && interactive()) { # If you have previously used `{renv}`, permission is implied use_package_cache(prompt = TRUE) # You can temporarily turn this off no_package_cache() getOption("sandpaper.use_renv") # should be FALSE use_package_cache(prompt = TRUE) }
if (!getOption("sandpaper.use_renv") && interactive()) { # The first time you set up `{renv}`, you will need permission use_package_cache(prompt = TRUE) # The package cache trigger is FALSE, by default default <- package_cache_trigger() # You can set this to `TRUE` when you update packages with `update_cache()` package_cache_trigger(TRUE) # set the trigger back to its former state package_cache_trigger(default) } if (getOption("sandpaper.use_renv") && interactive()) { # If you have previously used `{renv}`, permission is implied use_package_cache(prompt = TRUE) # You can temporarily turn this off no_package_cache() getOption("sandpaper.use_renv") # should be FALSE use_package_cache(prompt = TRUE) }