diff --git a/R/dependencies.R b/R/dependencies.R index 978f0839f..407484ade 100644 --- a/R/dependencies.R +++ b/R/dependencies.R @@ -2,29 +2,28 @@ #' Find R package dependencies in a project #' #' @description -#' `dependencies()` will crawl files within your project, looking for \R files +#' `dependencies()` will scan files within your project, looking for \R files #' and the packages used within those \R files. This is done primarily by #' parsing the code and looking for calls of the form `library(package)`, #' `require(package)`, `requireNamespace("package")`, and `package::method()`. #' renv also supports package loading with #' [box](https://cran.r-project.org/package=box) (`box::use(...)`) and -#' [pacman](https://cran.r-project.org/package=pacman) (`pacman::p_load(...)`) -#' . +#' [pacman](https://cran.r-project.org/package=pacman) (`pacman::p_load(...)`). #' #' For \R package projects, `renv` will also detect dependencies expressed #' in the `DESCRIPTION` file. For projects using Python, \R dependencies within #' the \R code chunks of your project's `.ipynb` files will also be used. #' #' Note that the \code{\link[rmarkdown:rmarkdown-package]{rmarkdown}} package is -#' required in order to crawl dependencies in R Markdown files. +#' required in order to scan dependencies in R Markdown files. #' #' # Missing dependencies #' #' `dependencies()` uses static analysis to determine which packages are used -#' by your project. This means that it inspects, but doesn't run, your -#' source. Static analysis generally works well, but is not 100% reliable in -#' detecting the packages required by your project. For example, renv is -#' unable to detect this kind of usage: +#' by your project. This means that it inspects, but doesn't run, the \R code +#' in your project. Static analysis generally works well, but is not +#' 100% reliable in detecting the packages required by your project. For +#' example, `renv` is unable to detect this kind of usage: #' #' ```{r eval=FALSE} #' for (package in c("dplyr", "ggplot2")) { @@ -33,8 +32,9 @@ #' ``` #' #' It also can't generally tell if one of the packages you use, uses one of -#' its suggested packages. For example, `tidyr::separate_wider_delim()` -#' uses the stringr package which is only suggested, not required by tidyr. +#' its suggested packages. For example, the `tidyr::separate_wider_delim()` +#' function requires the `stringr` package, but `stringr` is only suggested, +#' not required, by `tidyr`. #' #' If you find that renv's dependency discovery misses one or more packages #' that you actually use in your project, one escape hatch is to include a file @@ -46,25 +46,6 @@ #' library(stringr) #' ``` #' -#' # Explicit dependencies -#' -#' Alternatively, you can suppress dependency discover and instead rely -#' on an explicit set of packages recorded by you in a project `DESCRIPTION` file. -#' Call `renv::settings$snapshot.type("explicit")` to enable "explicit" mode, -#' then enumerate your dependencies in a project `DESCRIPTION` file. -#' -#' In that case, your `DESCRIPTION` might look something like this: -#' -#' ``` -#' Type: project -#' Description: My project. -#' Depends: -#' tidyverse, -#' devtools, -#' shiny, -#' data.table -#' ``` -#' #' # Ignoring files #' #' By default, renv will read your project's `.gitignore`s (if present) to diff --git a/R/snapshot.R b/R/snapshot.R index 2780dae5c..b4ce47e3c 100644 --- a/R/snapshot.R +++ b/R/snapshot.R @@ -16,12 +16,12 @@ the$auto_snapshot_hash <- TRUE #' providing lightweight portability and reproducibility without isolation. #' #' If you want to automatically snapshot after each change, you can -#' set `config$config$auto.snapshot(TRUE)`, see `?config` for more details. +#' set `config$config$auto.snapshot(TRUE)` -- see `?config` for more details. #' #' # Snapshot types #' -#' Depending on how you prefer to manage dependencies, you might prefer -#' selecting a different snapshot mode. The modes available are as follows: +#' Depending on how you prefer to manage your \R package dependencies, you may +#' want to enable an alternate snapshot type.. The types available are as follows: #' #' \describe{ #' @@ -38,7 +38,10 @@ the$auto_snapshot_hash <- TRUE #' \item{`"explicit"`}{ #' Only capture packages which are explicitly listed in the project #' `DESCRIPTION` file. This workflow is recommended for users who wish to -#' manage their project's \R package dependencies directly. +#' manage their project's \R package dependencies directly, and can be used +#' for both package and non-package \R projects. Packages used in this manner +#' should be recorded in either the `Depends` or `Imports` field of the +#' `DESCRIPTION` file. #' } #' #' \item{`"all"`}{ @@ -85,7 +88,7 @@ the$auto_snapshot_hash <- TRUE #' * `"all"` uses all packages in the project library. #' * `"custom"` uses a custom filter. #' -#' See **Snapshot type** below for more details. +#' See **Snapshot types** below for more details. #' #' @inheritParams dependencies #' diff --git a/man/dependencies.Rd b/man/dependencies.Rd index 475e2a7b6..ed8221042 100644 --- a/man/dependencies.Rd +++ b/man/dependencies.Rd @@ -60,28 +60,27 @@ package names to the files in which they were discovered. Note that the package name. } \description{ -\code{dependencies()} will crawl files within your project, looking for \R files +\code{dependencies()} will scan files within your project, looking for \R files and the packages used within those \R files. This is done primarily by parsing the code and looking for calls of the form \code{library(package)}, \code{require(package)}, \code{requireNamespace("package")}, and \code{package::method()}. renv also supports package loading with \href{https://cran.r-project.org/package=box}{box} (\code{box::use(...)}) and -\href{https://cran.r-project.org/package=pacman}{pacman} (\code{pacman::p_load(...)}) -. +\href{https://cran.r-project.org/package=pacman}{pacman} (\code{pacman::p_load(...)}). For \R package projects, \code{renv} will also detect dependencies expressed in the \code{DESCRIPTION} file. For projects using Python, \R dependencies within the \R code chunks of your project's \code{.ipynb} files will also be used. Note that the \code{\link[rmarkdown:rmarkdown-package]{rmarkdown}} package is -required in order to crawl dependencies in R Markdown files. +required in order to scan dependencies in R Markdown files. } \section{Missing dependencies}{ \code{dependencies()} uses static analysis to determine which packages are used -by your project. This means that it inspects, but doesn't run, your -source. Static analysis generally works well, but is not 100\% reliable in -detecting the packages required by your project. For example, renv is -unable to detect this kind of usage: +by your project. This means that it inspects, but doesn't run, the \R code +in your project. Static analysis generally works well, but is not +100\% reliable in detecting the packages required by your project. For +example, \code{renv} is unable to detect this kind of usage: \if{html}{\out{
}}\preformatted{for (package in c("dplyr", "ggplot2")) \{ library(package, character.only = TRUE) @@ -89,8 +88,9 @@ unable to detect this kind of usage: }\if{html}{\out{
}} It also can't generally tell if one of the packages you use, uses one of -its suggested packages. For example, \code{tidyr::separate_wider_delim()} -uses the stringr package which is only suggested, not required by tidyr. +its suggested packages. For example, the \code{tidyr::separate_wider_delim()} +function requires the \code{stringr} package, but \code{stringr} is only suggested, +not required, by \code{tidyr}. If you find that renv's dependency discovery misses one or more packages that you actually use in your project, one escape hatch is to include a file @@ -102,24 +102,6 @@ library(stringr) }\if{html}{\out{}} } -\section{Explicit dependencies}{ -Alternatively, you can suppress dependency discover and instead rely -on an explicit set of packages recorded by you in a project \code{DESCRIPTION} file. -Call \code{renv::settings$snapshot.type("explicit")} to enable "explicit" mode, -then enumerate your dependencies in a project \code{DESCRIPTION} file. - -In that case, your \code{DESCRIPTION} might look something like this: - -\if{html}{\out{
}}\preformatted{Type: project -Description: My project. -Depends: - tidyverse, - devtools, - shiny, - data.table -}\if{html}{\out{
}} -} - \section{Ignoring files}{ By default, renv will read your project's \code{.gitignore}s (if present) to determine whether certain files or folders should be included when traversing diff --git a/man/lockfiles.Rd b/man/lockfiles.Rd index 83c4cfed4..5612c3008 100644 --- a/man/lockfiles.Rd +++ b/man/lockfiles.Rd @@ -40,7 +40,7 @@ lockfile_modify( \item \code{"custom"} uses a custom filter. } -See \strong{Snapshot type} below for more details.} +See \strong{Snapshot types} below for more details.} \item{libpaths}{The library paths to be used when generating the lockfile.} diff --git a/man/snapshot.Rd b/man/snapshot.Rd index b21db42b0..a23f12e0a 100644 --- a/man/snapshot.Rd +++ b/man/snapshot.Rd @@ -44,7 +44,7 @@ directly instead.} \item \code{"custom"} uses a custom filter. } -See \strong{Snapshot type} below for more details.} +See \strong{Snapshot types} below for more details.} \item{dev}{Boolean; include development dependencies? These packages are typically required when developing the project, but not when running it @@ -97,11 +97,11 @@ current library paths. This makes it possible to \link{restore} the current pack providing lightweight portability and reproducibility without isolation. If you want to automatically snapshot after each change, you can -set \code{config$config$auto.snapshot(TRUE)}, see \code{?config} for more details. +set \code{config$config$auto.snapshot(TRUE)} -- see \code{?config} for more details. } \section{Snapshot types}{ -Depending on how you prefer to manage dependencies, you might prefer -selecting a different snapshot mode. The modes available are as follows: +Depending on how you prefer to manage your \R package dependencies, you may +want to enable an alternate snapshot type.. The types available are as follows: \describe{ @@ -118,7 +118,10 @@ explicit mode, as described next. \item{\code{"explicit"}}{ Only capture packages which are explicitly listed in the project \code{DESCRIPTION} file. This workflow is recommended for users who wish to -manage their project's \R package dependencies directly. +manage their project's \R package dependencies directly, and can be used +for both package and non-package \R projects. Packages used in this manner +should be recorded in either the \code{Depends} or \code{Imports} field of the +\code{DESCRIPTION} file. } \item{\code{"all"}}{