loads or reloads if needed a source package, taking care of its dependencies
Source:R/pkg_load.R
pkg_load.RdN.B: the defaults are different from devtools::load_all(): the helpers are not loaded, only
the functions tagged as exported are actually exported. The intended goal is to make it as similar
to the behaviour of the R loaders.
Usage
pkg_load(
pkgid,
src_pkgs = get_srcpkgs(),
attach = TRUE,
suggests = FALSE,
roxygen = TRUE,
helpers = FALSE,
export_all = FALSE,
quiet = FALSE,
dry_run = FALSE,
...
)Arguments
- pkgid
a package name, path or package object
- src_pkgs
a collection of source packages as a
srckgsobject.- attach
Whether to attach a package environment to the search path. If
FALSEload_all()behaves likeloadNamespace(). IfTRUE(the default), it behaves likelibrary(). IfFALSE, theexport_all,export_imports, andhelpersarguments have no effect.- suggests
whether to load suggested packages. if TRUE, the suggested are processed like imports
- roxygen
whether to automatically roxygenise packages (if needed)
- helpers
if
TRUEloads testthat test helpers.- export_all
If
TRUE(the default), export all objects. IfFALSE, export only the objects that are listed as exports in the NAMESPACE file.- quiet
whether to be quiet/silent
- dry_run
whether not to actually execute any action having side-effects
- ...
Arguments passed on to
devtools::load_allpathPath to a package, or within a package.
resetclear package environment and reset file cache before loading any pieces of the package. This largely equivalent to running
unload(), however the old namespaces are not completely removed and no.onUnload()hooks are called. Usereset = FALSEmay be faster for large code bases, but is a significantly less accurate approximation.recompileDEPRECATED. force a recompile of DLL from source code, if present. This is equivalent to running
pkgbuild::clean_dll()beforeload_all
Details
This the workhorse function of the package, called by library() and loadNamespace()
when hacked (cf hack_r_loaders().
This function will check that all dependent packages are up-to-date, and document and reload them as needed.
To be able to properly load a package, its dependent source packages must be loaded in proper order. i.e. if A–>B–>C, the load order must be C, B, A
Examples
if (FALSE) { # \dontrun{
# N.B: This example is wrapped in \dontrun as it cannot be executed since it requires
# a source package to load.
# load and attach a package
pkg_load('mypkg')
# just load, do not attach it (~ loadNamespace())
pkg_load('mypkg', attach = FALSE)
# do some changes, to a source package or any of its depencies or dependents
plan <- pkg_load('mypkg', dry_run = TRUE)
# then you can inspect the plan actions
} # }