Set up a package to use altdown

Description

Writes altdoc/altdown.yml, the one configuration file build_site() reads, with a starter reference: field listing every function currently documented in <path>/man/*.Rd in one "All functions" section. Also adds the .gitignore/.Rbuildignore entries the build needs (see Details) if they’re not already there.

Usage

use_altdown(path = ".")

Arguments

path Path to the target package root. Defaults to the current directory.

Details

An existing altdoc/altdown.yml is never overwritten. If the package was set up with an earlier version of altdown, the reference: field is taken over from its altdoc/reference.yml; that file, and the altdoc/build-site.R and altdoc/quarto_website_static.yml copies, are no longer used and can be deleted.

use_altdown() adds the following lines to .gitignore and .Rbuildignore (only the ones not already present in each file):

# .gitignore
_quarto/*
!_quarto/_freeze/
altdoc/freeze.rds
altdoc/pkgdown.yml
altdoc/quarto_website.yml
altdoc/index.md
altdoc/reference.qmd
altdoc/authors.qmd
altdoc/altdown.scss
altdoc/altdown-header.html
altdoc/altdown-after-body.html
altdoc/altdown-pre-render.R

# .Rbuildignore
^docs\$
^altdoc\$
^_quarto\$

The first four mirror what altdoc::setup_docs(tool = "quarto_website") adds, plus altdoc/pkgdown.yml, which altdoc::render_docs() rewrites on every build. The rest are the files build_site() generates.

Value

Invisibly, the path to the altdoc/ directory.

Examples

pkg <- tempfile("examplepkg")
dir.create(pkg)
write(
  "Package: examplepkg\nVersion: 0.0.0.9000",
  file.path(pkg, "DESCRIPTION")
)
use_altdown(pkg)
list.files(file.path(pkg, "altdoc"))
#> [1] "altdown.yml"
unlink(pkg, recursive = TRUE)