Package 'pkgdev'

Title: Helpers to Develop a Package using GitHub Actions
Description: A small set of functions that takes advantage of GitHub Actions for making your life easier as a R package developer. This package is primarily intended for personal use, however feel free to use it (at your own risk :)).
Authors: Diego Hernangómez [aut, cre, cph]
Maintainer: Diego Hernangómez <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0.9060
Built: 2024-12-16 09:27:00 UTC
Source: https://github.com/dieghernan/pkgdev

Help Index


Add .gitignore to package

Description

Adds a global .gitgnore file to the package. File based on default .gitignore provided by GitHub.

Usage

add_global_gitgnore(pkg = ".")

Arguments

pkg

Path to a (subdirectory of an) R package.

Value

Invisible, and writes a global .gitignore file

See Also

usethis::use_git_ignore(), usethis::git_vaccinate()

Examples

## Not run: 
add_global_gitgnore()

## End(Not run)

Check the titles of a Rd file

Description

Check if title of Rd files ends in a period.

Usage

check_rd_titles(pkg = ".")

Arguments

pkg

Path to a (subdirectory of an) R package.

Value

A data frame with the results.

Examples

## Not run: 

check_rd_titles()

## End(Not run)

Create a GitHub action that checks regularly your package

Description

The GitHub action created would run ⁠R CMD check⁠ on your package. It uses a wide range of platforms, can be reduced by commenting or deleting platforms on the matrix config.

Usage

gha_check_full(pkg = ".", overwrite = TRUE, cron_expr = "30 08 1 * *")

Arguments

pkg

Path to a (subdirectory of an) R package.

overwrite

Overwrite the action if it was already present.

cron_expr

Valid cron expression. By default, the first day of the month at 08:30 AM. See Details.

Details

Use crontab.guru to check and create your own cron tag.

Value

A GitHub Action on ⁠<pkg>/.github/workflows⁠.

Source

r-lib/actions

See Also

usethis::use_github_action_check_full()

Examples

## Not run: 
gha_check_full(cron_expr = "57 16 12 * *")

## End(Not run)

Create a GitHub action that builds a pkgdown site

Description

The GitHub action created would deploy a pkgdown site of your package on the gh-pages branch.

Usage

gha_pkgdown_branch(
  pkg = ".",
  overwrite = TRUE,
  platform = "macOS",
  version = "latest"
)

Arguments

pkg

Path to a (subdirectory of an) R package.

overwrite

Overwrite the action if it was already present.

platform

Platform to use for deploying the package. See Details

version

Version of the platform. See Details.

Details

Check https://github.com/actions/runner-images to see the available options.

Value

A GitHub Action on ⁠<pkg>/.github/workflows⁠.

Source

r-lib/actions

See Also

gha_check_full()

Examples

## Not run: 
# With Ubuntu 20.04
gha_pkgdown_branch(platform = "ubuntu", version = "20.04")

## End(Not run)

Create a GitHub action that documents and checks your package

Description

The GitHub action created would document your package (see update_docs()), would check it and would deploy the package on a gh-pages branch.

Usage

gha_update_docs(
  pkg = ".",
  overwrite = TRUE,
  platform = "macOS",
  version = "latest"
)

Arguments

pkg

Path to a (subdirectory of an) R package.

overwrite

Overwrite the action if it was already present.

platform

Platform to use for deploying the package. See Details

version

Version of the platform. See Details.

Details

Check https://github.com/actions/runner-images to see the available options.

Value

A GitHub Action on .github/workflows.

Source

r-lib/actions

See Also

update_docs(), gha_pkgdown_branch()

Examples

## Not run: 
# With Ubuntu 20.04
gha_update_docs(platform = "ubuntu", version = "20.04")

## End(Not run)

Precompute vignettes

Description

Precompute vignettes from CRAN, based on https://ropensci.org/blog/2019/12/08/precompute-vignettes/.

Usage

precompute_vignette(
  source,
  pkg = ".",
  figure_ext = ".png",
  create_r_file = FALSE
)

precompute_vignette_all(dir = "vignettes", pkg = ".", ...)

Arguments

source

Name without path of the .Rmd.orig file (e.g. "some_name.Rmd.orig").

pkg

Path to a (subdirectory of an) R package.

figure_ext

Extension of the figures plotted on the vignette. See Details.

create_r_file

Whether to create an additional R file with the code of the vignette.

dir

Path to directory where the "Rmd.orig" files are stored.

...

Parameters passed to precompute_vignette().

Details

The function would search for the desired precomputed vignette on the "./vignettes/" folder and for plots on the root "./" folder.

Important

On your .Rmd.orig file make sure you have set at least the following lines if you are producing plots:

knitr::opts_chunk$set(
  ... ,
  fig.path = "./",
  ... ,
  )

Value

A precomputed vignette

Source

https://ropensci.org/blog/2019/12/08/precompute-vignettes/

Examples

## Not run: 

precompute_vignette(source = "precompute.Rmd.orig")

## End(Not run)

Document your package

Description

Run routine checks on the package:

Usage

update_docs(
  pkg = ".",
  url_update = TRUE,
  create_codemeta = TRUE,
  create_cff = TRUE,
  build_readme = TRUE,
  verbose = TRUE,
  precompute = TRUE,
  opt_imgs = TRUE,
  opt_dir = c("pkgdown/favicon", "man/figures", "vignettes"),
  opt_ext = "png$|jpg$",
  opt_overwrite = TRUE,
  ...
)

Arguments

pkg

Path to a (subdirectory of an) R package.

url_update

Logical, do you want to update urls with urlchecker::url_update()?

create_codemeta

Logical, do you want to create a codemeta file with codemetar::write_codemeta()?

create_cff

Logical, do you want to create a CITATION.cff file with cffr::cff_write()?

build_readme

Logical, build README.Rmd with devtools::build_readme()

verbose

Display informative messages on the console

precompute

Logical, detect and precompute vignettes? See also precompute_vignette().

opt_imgs

Logical. Optimize images with resmush::resmush_dir()?

opt_dir, opt_ext, opt_overwrite

See dir, ext and overwrite in resmush::resmush_dir().

...

Additional arguments to functions

Details

This function tries to update and clean the package following a mix of best practices (e.g. checking the urls, roxygenise and rebuilding the README) and some other discretionary practices I like to have in a package, as the tidyverse approach for the DESCRIPTION file and overall code and the use of codemeta.json.

Value

invisible, or some messages on verbose = TRUE.

See Also

usethis::use_tidy_description(), styler::style_pkg(), urlchecker::url_check(), roxygen2::roxygenise(), devtools::build_readme(), codemetar::write_codemeta(), tools::resaveRdaFiles()

Examples

## Not run: 

update_docs()

## End(Not run)