Site icon R-bloggers

{attachment} v0.4.0: Breaking changes and configuration file for a better experience

[This article was first published on Rtask, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

You can read the original post in its original format on Rtask website by ThinkR here: {attachment} v0.4.0: Breaking changes and configuration file for a better experience

{attachment} v0.4.0 stores your parameters in a configuration file for an easier use during your package development: run att_amend_desc() from anywhere, it will re-use your last set of parameters.  This comes with some breaking changes for a better experience.

 

The goal of attachment is to help to deal with package dependencies during package development. It also gives useful tools to install or list missing packages used inside Rscripts, Rmds or qmd. This reads your NAMESPACE, your functions in R directory and your vignettes, then update the DESCRIPTION file accordingly. Are you ready to be lazy ? Let {attachment} help you !

Installation

{attachment} is available on CRAN and developed on GitHub. You can access the full documentation website on this page: https://thinkr-open.github.io/attachment. It also appears on the ThinkR r-universe page if you want to install the development version without GitHub API constraints.

Install CRAN version

install.packages("attachment")

Install development version

install.packages('attachment', repos = c('https://thinkr-open.r-universe.dev', 'https://cloud.r-project.org'))

Declare all dependencies in DESCRIPTION during package development

What you really want is to fill and update your description file along with the modifications of your documentation. Indeed, only the following function will really be called. Use and abuse during the development of your package !

attachment::att_amend_desc()

{attachment} detects all calls to library(pkg), @importFrom pkg fun, pkg::fun() in the different classical directories of your R package, then list them in the correct “Imports” or “Suggests” category in the DESCRIPTION file, according to their position in the package.

Declare extra dependencies for extra uses

If you want to add extra packages like {pkgdown} or {covr} that are not listed in any script in your package, a call for your development packages would be:

attachment::att_amend_desc(extra.suggests = c("pkgdown", "covr"), update.config = TRUE)

Note the update.config = TRUE parameter that will save the parameters used in the call of att_amend_desc() to the package configuration file: “dev/config_attachment.yaml”.

If you run att_amend_desc() a second time afterwards, directly from the console, it will use the last set of parameters extracted from the configuration file.

Indeed, we recommend to store the complete command line in a “dev/dev_history.R” file to update and run it when needed. If the parameters do not change, you can run attachment::att_amend_desc() directly in the console, wherever you are, it will use the configuration file.

Automatically fill the “Remotes” field

If you would like to detect the sources of your installations so that you can add dependencies in the “Remotes” field of your DESCRIPTION file, to mimic your local installation, you will use:

attachment::set_remotes_to_desc()

 

Combination of {attachment} with {fusen}

The configuration file of {attachment} was originally developed for a better integration with {fusen}. Indeed, when you inflate() your notebook file into a fully documented R package, {fusen} automatically runs attachment::att_amend_desc() to update your documentation and the list of dependencies of your package. However, until now, it was not possible to use extra parameters in the inflate() function to be used by {attachment}, and you had to stop the automatic detection with document = FALSE, then run your specific {attachment} code from somewhere else.

As we are all lazy, we do not want to change file each time we have to introduce a new changes in our package. With the configuration file of {attachment}, you can let your fusen::inflate() as is, and it will use the last version of attachment::att_amend_desc() according to what’s in the configuration file.  If you want to change the default parameters, by adding extra dependencies for instance, you will have to change the configuration file only once. To do so, you’ll surely want to update your “dev/0-dev_history.Rmd” file with this code to run once:

attachment::att_amend_desc(extra.suggests = c("pkgdown", "covr"), update.config = TRUE)

 

NEWS content

Breaking changes

New features

Bug fixes

This post is better presented on its original ThinkR website here: {attachment} v0.4.0: Breaking changes and configuration file for a better experience

To leave a comment for the author, please follow the link and comment on their blog: Rtask.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Exit mobile version