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-10-17 13:54:23 UTC
Source: https://github.com/dieghernan/pkgdev

Help Index


Add a global .gitignore file to a 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 the package root directory.

Value

NULL, invisibly, after updating .gitignore files.

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 Quarto file in a clean R session. build_readme_qmd() locates your README.qmd and builds it into 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

A logical value, TRUE, invisibly, after rendering the Quarto files.

See Also

Documentation rendering helpers: precompute_vignette()


Inspect Rd file titles

Description

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

Usage

check_rd_titles(pkg = ".")

Arguments

pkg

Path to the package root directory.

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. Returns NULL if no Rd files are found.

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 the package root directory.

overwrite

Whether to overwrite an existing workflow file.

cron_expr

A valid cron expression. Defaults to 08:30 UTC on the first day of the month. See Details.

Details

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

Value

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

Source

Examples from r-lib/actions.

See Also

usethis::use_github_action() creates GitHub Actions workflows.

GitHub Actions workflow 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 to the gh-pages branch.

Usage

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

Arguments

pkg

Path to the package root directory.

overwrite

Whether to overwrite an existing workflow file.

platform

Runner operating system to use for deploying the site. See Details.

version

Runner image version. See Details.

Details

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

Value

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

Source

Examples from r-lib/actions.

See Also

pkgdown::build_site() builds the package website locally.

GitHub Actions workflow 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 its pkgdown site to the gh-pages branch.

Usage

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

Arguments

pkg

Path to the package root directory.

overwrite

Whether to overwrite an existing workflow file.

platform

Runner operating system to use for deploying the site. See Details.

version

Runner image version. See Details.

Details

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

Value

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

Source

Examples from r-lib/actions.

See Also

update_docs() documents and checks your package.

GitHub Actions workflow 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 following the CRAN approach described at 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 or .qmd.orig file, without the path (e.g. "some_name.Rmd.orig" or "some_name.qmd.orig").

pkg

Path to the package root directory.

figure_ext

File extension for figures plotted in the vignette. See Details.

create_r_file

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

dir

Path to the directory where the .Rmd.orig and .qmd.orig files are stored.

...

Additional arguments passed to precompute_vignette().

Details

This function reads vignette source files from the package's vignettes directory and moves plots from the package root to that directory.

precompute_vignette() processes the files named in source. precompute_vignette_all() finds and processes every .Rmd.orig and .qmd.orig file in dir.

Important

In your .Rmd.orig or .qmd.orig file, set the following chunk option when producing plots:

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

Value

NULL, invisibly, after precomputing the vignettes.

Source

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

See Also

update_docs() runs the broader package maintenance workflow.

Documentation rendering helpers: build_qmd()

Examples

## Not run: 
precompute_vignette(source = "precompute.Rmd.orig")

## End(Not run)

Document your package

Description

Performs routine package maintenance:

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 the package root directory.

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.qmd, README.Rmd or pkgdown index files be built?

verbose

A logical value. Should progress messages be displayed in the console?

precompute

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

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 checks URLs, regenerates roxygen2 documentation and rebuilds the README. It also applies the tidyverse style to DESCRIPTION and package code and writes package metadata to codemeta.json.

Value

NULL, invisibly, after updating the package. Emits progress messages when verbose = TRUE.

See Also

Package maintenance helpers: add_global_gitgnore()

Examples

## Not run: 
update_docs()

## End(Not run)