Package 'pkgdev'

Title: Helpers to Develop Packages with GitHub Actions
Description: Helpers for package maintenance, documentation rendering and GitHub Actions workflows. The package is primarily intended for personal use, but you are welcome to use it at your own risk.
Authors: Diego Hernangómez [aut, cre, cph] (ORCID: <https://orcid.org/0000-0001-8457-4658>)
Maintainer: Diego Hernangómez <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0.9150
Built: 2026-07-15 20:45:44 UTC
Source: https://github.com/dieghernan/pkgdev

Help Index


Add .gitignore to package

Description

Adds a global .gitignore file to the package. The file is based on the default .gitignore provided by GitHub.

Usage

add_global_gitgnore(pkg = ".")

Arguments

pkg

Path to a (subdirectory of an) R package.

Value

Invisibly returns NULL after writing a global .gitignore file.

See Also

Package maintenance helpers: update_docs()

Examples

## Not run: 
add_global_gitgnore()

## End(Not run)

Build Quarto files for a package

Description

build_qmd() is a wrapper around quarto::quarto_render() that first installs a temporary copy of the package, then renders each .Rmd in a clean R session. build_readme_qmd() locates your README.qmd and builds it into a README.md.

Usage

build_qmd(files, path = ".", ..., quiet = TRUE)

build_readme_qmd(path = ".", quiet = TRUE, ...)

Arguments

files

Quarto files to be rendered.

path

Path to the top-level directory of the source package.

...

Additional arguments passed to quarto::quarto_render().

quiet

If TRUE, suppresses most output. Set to FALSE if you need to debug.

Value

TRUE, invisibly.

See Also

Documentation renderers: precompute_vignette()


Inspect Rd file titles

Description

Inspect generated Rd file titles for sentence case and trailing periods.

Usage

check_rd_titles(pkg = ".")

Arguments

pkg

Path to a (subdirectory of an) R package.

Value

A data frame with one row per Rd file and columns for the source path, title, sentence-case title, final character and sentence-case check.

See Also

update_docs() runs this check after roxygenizing the package.

Examples

## Not run: 
check_rd_titles()

## End(Not run)

Create a GitHub Actions workflow that checks your package regularly

Description

The GitHub Actions workflow runs ⁠R CMD check⁠ on your package. It uses a wide range of platforms, which can be reduced by commenting out or deleting platforms in the matrix configuration.

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

Invisibly returns NULL after writing a GitHub Actions workflow to ⁠<pkg>/.github/workflows⁠.

Source

Examples from r-lib/actions.

See Also

GitHub Actions helpers: gha_pkgdown_branch(), gha_update_docs()

Examples

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

## End(Not run)

Create a GitHub Actions workflow that builds a pkgdown site

Description

The GitHub Actions workflow deploys a pkgdown site for 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

Invisibly returns NULL after writing a GitHub Actions workflow to ⁠<pkg>/.github/workflows⁠.

Source

Examples from r-lib/actions.

See Also

GitHub Actions helpers: gha_check_full(), gha_update_docs()

Examples

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

## End(Not run)

Create a GitHub Actions workflow that documents and checks your package

Description

The GitHub Actions workflow documents your package (see update_docs()), checks it and deploys 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

Invisibly returns NULL after writing a GitHub Actions workflow to .github/workflows.

Source

Examples from r-lib/actions.

See Also

GitHub Actions helpers: gha_check_full(), 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 using the CRAN approach, 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 of the .Rmd.orig file, without the path (e.g. "some_name.Rmd.orig").

pkg

Path to a (subdirectory of an) R package.

figure_ext

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

create_r_file

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

dir

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

...

Parameters passed to precompute_vignette().

Details

This function searches for the desired precomputed vignette in the "./vignettes/" directory and for plots in the root "./" directory.

Important

In 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

Invisibly returns NULL after writing a precomputed vignette.

Source

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

See Also

Documentation renderers: build_qmd()

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("man/figures", "vignettes"),
  opt_ext = "png$|jpg$",
  opt_overwrite = TRUE,
  add_contributors = TRUE,
  ...
)

Arguments

pkg

Path to a (subdirectory of an) R package.

url_update

A logical value. Should URLs be updated with urlchecker::url_update()?

create_codemeta

A logical value. Should codemeta.json be created with codemetar::write_codemeta()?

create_cff

A logical value. Should CITATION.cff be created with cffr::cff_write()?

build_readme

A logical value. Should README.Rmd be built with devtools::build_readme()?

verbose

A logical value. Should informative messages be displayed on the console?

precompute

A logical value. Should vignettes be detected and precomputed? See also precompute_vignette().

opt_imgs

A logical value. Should images be optimized with resmush::resmush_dir()?

opt_dir, opt_ext, opt_overwrite

Options passed to the dir, ext and overwrite arguments of resmush::resmush_dir().

add_contributors

Deprecated.

...

Additional arguments passed to downstream functions.

Details

This function updates and cleans the package using a mix of best practices, such as checking URLs, roxygenizing and rebuilding the README. It also applies discretionary practices such as the tidyverse approach for the DESCRIPTION file, overall code style and codemeta.json.

Value

Invisibly returns NULL. When verbose = TRUE, it emits progress messages.

See Also

Package maintenance helpers: add_global_gitgnore()

Examples

## Not run: 
update_docs()

## End(Not run)