Skip to contents

N.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 object

src_pkgs

a collection of source packages as a srckgs object.

attach

Whether to attach a package environment to the search path. If FALSE load_all() behaves like loadNamespace(). If TRUE (the default), it behaves like library(). If FALSE, the export_all, export_imports, and helpers arguments 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 TRUE loads testthat test helpers.

export_all

If TRUE (the default), export all objects. If FALSE, 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_all

path

Path to a package, or within a package.

reset

clear 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. Use reset = FALSE may be faster for large code bases, but is a significantly less accurate approximation.

recompile

DEPRECATED. force a recompile of DLL from source code, if present. This is equivalent to running pkgbuild::clean_dll() before load_all

Value

the load plan as a data frame, or NULL if there is nothing to do.

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) {
# 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

}