add_deps: Add required dependencies to the description file

View source: R/add_deps.R

add_depsR Documentation

Add required dependencies to the description file

Description

This function detects external packages used in an R project (package, compendium, website, etc.) and updates the sections Depends, Imports, and Suggests of the DESCRIPTION file.

A DESCRIPTION file can be created and added to an existing project with the function usethis::use_description().

All .R, .Rmd, and .qmd files are screened to identify packages called by library(foo), library("foo"), library('foo'), require(foo), require("foo"), require('foo') or foo::bar().

Different types of dependencies are handled with the following rules:

  • if a package is called with library(foo) or require(foo), it will be added to the section Depends of the DESCRIPTION file (except for vignettes and tests);

  • if the package is called with foo::bar(), it will be added to the section Imports of the DESCRIPTION file (except for vignettes and tests);

  • if the package is only used in vignettes or tests, it will be added to the section Suggests of the DESCRIPTION file.

This function also screens the NAMESPACE file (it detects packages mentioned as import(foo) and importFrom(foo,bar)) and ⁠@examples⁠ sections of roxygen2 headers. The detected packages are added in the Imports section of the DESCRIPTION file.

If the project is not an R package, non-standard folders are also screened (i.e. ⁠analyses/⁠, ⁠paper/⁠, etc.). The detected packages are added in the Imports section of the DESCRIPTION file.

Usage

add_deps()

Value

No return value.

Examples

## Not run: 
add_deps()

## End(Not run)

rdeps documentation built on May 29, 2024, 8:16 a.m.