All Projects → ThinkR-open → Attachment

ThinkR-open / Attachment

Licence: gpl-3.0
Tools to deal with dependencies in scripts, Rmd and packages

Programming Languages

r
7636 projects

Projects that are alternatives of or similar to Attachment

Openwisp Network Topology
Network topology collector and visualizer. Collects network topology data from dynamic mesh routing protocols or other popular networking software like OpenVPN, allows to visualize the network graph, save daily snapshots that can be viewed in the future and more.
Stars: ✭ 67 (-2.9%)
Mutual labels:  hacktoberfest
Anime Downloader
A simple but powerful anime downloader and streamer.
Stars: ✭ 1,155 (+1573.91%)
Mutual labels:  hacktoberfest
Molecule Vagrant
Molecule Vangrant Driver
Stars: ✭ 69 (+0%)
Mutual labels:  hacktoberfest
Ratp Api Rest
This project turnkey is distributed as a middleware to expose RATP realtime data as REST resources
Stars: ✭ 68 (-1.45%)
Mutual labels:  hacktoberfest
Express Jsdoc Swagger
Swagger OpenAPI 3.x generator
Stars: ✭ 69 (+0%)
Mutual labels:  hacktoberfest
Mahapps.metro.iconpacks
Awesome icon packs for WPF and UWP in one library
Stars: ✭ 1,157 (+1576.81%)
Mutual labels:  hacktoberfest
Brawlstats
(A)sync python wrapper for the Brawl Stars API
Stars: ✭ 68 (-1.45%)
Mutual labels:  hacktoberfest
Pretty Print
pretty print module for the jvm
Stars: ✭ 69 (+0%)
Mutual labels:  hacktoberfest
Wise Old Man
The Open Source Old School Runescape progress tracker.
Stars: ✭ 68 (-1.45%)
Mutual labels:  hacktoberfest
Harmonyx
Harmony built on top of MonoMod.RuntimeDetours with additional features
Stars: ✭ 69 (+0%)
Mutual labels:  hacktoberfest
Escpos Printer Db
Database of ESC/POS thermal receipt printers
Stars: ✭ 68 (-1.45%)
Mutual labels:  hacktoberfest
Image Gif
GIF en- and decoder
Stars: ✭ 68 (-1.45%)
Mutual labels:  hacktoberfest
Sceptre
Build better AWS infrastructure
Stars: ✭ 1,160 (+1581.16%)
Mutual labels:  hacktoberfest
Elmyr
A utility to make Kotlin/Java tests random yet reproducible
Stars: ✭ 68 (-1.45%)
Mutual labels:  hacktoberfest
Birolipsum
Birolipsum é um gerador de Lorem Ipsum com citações do (infelizmente) presidente do Brasil, Jair Bolsonaro (ou Biroliro para os íntimos).
Stars: ✭ 69 (+0%)
Mutual labels:  hacktoberfest
Vue Lunar Calendar
A vue component for lunar calendar.
Stars: ✭ 68 (-1.45%)
Mutual labels:  hacktoberfest
Parse Sdk Js
The JavaScript SDK for the Parse Platform
Stars: ✭ 1,158 (+1578.26%)
Mutual labels:  hacktoberfest
Fury
FURY - Free Unified Rendering in pYthon.
Stars: ✭ 68 (-1.45%)
Mutual labels:  hacktoberfest
Terraform Aws Airflow
Terraform module to deploy an Apache Airflow cluster on AWS, backed by RDS PostgreSQL for metadata, S3 for logs and SQS as message broker with CeleryExecutor
Stars: ✭ 69 (+0%)
Mutual labels:  hacktoberfest
Indico
Indico - A feature-rich event management system, made @ CERN, the place where the Web was born.
Stars: ✭ 1,160 (+1581.16%)
Mutual labels:  hacktoberfest

R build status Coverage status CRAN status downloads

attachment

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 or Rmds.

When building a package, we have to add @importFrom in our documentation or pkg::fun in the R code. The most important is not to forget to add the list of dependencies in the “Imports” or “Suggests” package lists in the DESCRIPTION file.

Why do you have to repeat twice the same thing ?
And what happens when you remove a dependency for one of your functions ? Do you really want to run a “Find in files” to verify that you do not need this package anymore ?

Let {attachment} help you ! This reads your NAMESPACE, your functions in R directory and your vignettes, then update the DESCRIPTION file accordingly. Are you ready to be lazy ?

See full documentation realized using {pkgdown} at https://thinkr-open.github.io/attachment/

Installation

CRAN version

install.packages("attachment")

Development version

# install.packages("devtools")
devtools::install_github("ThinkR-open/attachment")

Use package {attachment}

During package development

library(attachment)

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()

As {pkgdown} and {covr} are not listed in any script in your package, a common call for your development packages would be:

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

Note: attachment::att_to_description() is Deprecated.

Example on a fake package

# Copy package in a temporary directory
tmpdir <- tempdir()
file.copy(system.file("dummypackage",package = "attachment"), tmpdir, recursive = TRUE)
#> [1] TRUE
dummypackage <- file.path(tmpdir, "dummypackage")
# browseURL(dummypackage)
att_amend_desc(path = dummypackage, inside_rmd = TRUE)
#> Updating dummypackage documentation
#> Updating roxygen version in /tmp/Rtmpl1G8Z3/dummypackage/DESCRIPTION
#> Loading dummypackage
#> Writing NAMESPACE
#> Writing NAMESPACE
#> Package(s) Rcpp is(are) in category 'LinkingTo'. Check your Description file to be sure it is really what you want.
#> [-] 1 package(s) removed: utils.
#> [+] 2 package(s) added: stats, ggplot2.

For installation

To quickly install missing packages from a DESCRIPTION file, use:

attachment::install_from_description()
#> All required packages are installed

To quickly install missing packages needed to compile Rmd files or run Rscripts, use:

attachment::att_from_rmds(path = ".") %>% attachment::install_if_missing()

attachment::att_from_rscripts(path = ".") %>% attachment::install_if_missing()

Function attachment::create_dependencies_file() will create a dependencies.R file in inst/ directory. This R script contains the procedure to quickly install missing dependencies:

# No Remotes ----
# remotes::install_github("ThinkR-open/fcuk")
# Attachments ----
to_install <- c("covr", "desc", "devtools", "glue", "knitr", "magrittr", "rmarkdown", "stats", "stringr", "testthat", "utils")
for (i in to_install) {
  message(paste("looking for ", i))
  if (!requireNamespace(i)) {
    message(paste("     installing", i))
    install.packages(i)
  }
}

For bookdown

If you write a {bookdown} and want to publish it on Github using Travis for instance, you will need a DESCRIPTION file with list of dependencies just like for a package. In this case, you can use the function to description from import/suggest: att_to_desc_from_is().

# bookdown Imports are in Rmds
imports <- c("bookdown", attachment::att_from_rmds("."))
attachment::att_to_desc_from_is(path.d = "DESCRIPTION",
                                imports = imports, suggests = NULL)

To list information

Of course, you can also use {attachment} out of a package to list all package dependencies of R scripts using att_from_rscripts() or Rmd files using att_from_rmds().
If you are running this inside a Rmd, you may need parameter inside_rmd = TRUE.

dummypackage <- system.file("dummypackage", package = "attachment")

att_from_rscripts(path = dummypackage)
#> [1] "stats"        "base"         "testthat"     "dummypackage"
att_from_rmds(path = file.path(dummypackage, "vignettes"), inside_rmd = TRUE)
#> [1] "knitr"     "rmarkdown" "ggplot2"

Vignette

Package {attachment} has a vignette to present the different functions available. There is also a recommendation to have a devstuff_history.R in the root directory of your package. (Have a look at devstuff_history.R in the present package)

vignette("fill-pkg-description", package = "attachment")

The vignette is available on the {pkgdown} page: https://thinkr-open.github.io/attachment/articles/fill-pkg-description.html

See full documentation realized using {pkgdown} at https://thinkr-open.github.io/attachment/

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].