Skip to content

Commit

Permalink
documentation tweaks (#2070)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinushey committed Jan 10, 2025
1 parent 30cf3b6 commit 5ea4b29
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 68 deletions.
39 changes: 10 additions & 29 deletions R/dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand All @@ -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
Expand All @@ -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
Expand Down
13 changes: 8 additions & 5 deletions R/snapshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -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{
#'
Expand All @@ -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"`}{
Expand Down Expand Up @@ -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
#'
Expand Down
38 changes: 10 additions & 28 deletions man/dependencies.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/lockfiles.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions man/snapshot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5ea4b29

Please sign in to comment.