When {sandpaper} is loaded (either by attatchment with library() or invocation with ::, a function called .onLoad() (which lives in R/zzz.R) is evaluated:
sandpaper:::.onLoad
function (libname, pkgname)
{
ns <- asNamespace(pkgname)
delayedAssign("GITIGNORED", gitignore_items(), eval.env = ns,
assign.env = ns)
op <- getOption("sandpaper.use_renv")
if (is.null(op)) {
try_use_renv()
}
establish_translation_vars()
invisible()
}
<bytecode: 0x5567f6f01958>
<environment: namespace:sandpaper>
This does a few things:
establishes a GITIGNORED vector that is used to check the .gitignore file to validate that we are working in a lesson that The Workbench can work with.
attempts to determine if the user has provided consent to use {renv} with try_use_renv(). This will set the internal sandpaper.use_renv environment variable.
The establish_translation_vars() will establish the internal list of translation strings inside the internal environment called these$translations for use with set_language(), which can be fetched with the tr_src(), and tr_get() functions. See establish_translation_vars() for details
8.2 Building the lesson
All functions that build a lesson go through build_lesson():
Because all of the lesson functions need to understand where the lesson exists on the file system, we want to record the root path while a lesson is being deployed. When build_lesson() is run, it calls the set_source_path() function, which records the root of the lesson (as determined by the presence of an “episodes” directory, OR a “site” directory, OR a “learners” directory, OR an “instructors” directory, OR a “profiles” directory) in a global envioronment called .build_paths$source:
When validate_lesson() is called, it kicks off a cascade that stores lesson-specific variables and strings for {varnish} into the language of the lesson. This process is described in The Data Flow vingette for {sandpaper}