Set up altdown’s altdoc template in a package

Description

Copies altdown’s altdoc/ template (build-site.R, altdown.scss, quarto_website_static.yml) into <path>/altdoc/, and writes a starter altdoc/reference.yml 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 = ".", overwrite = FALSE)

Arguments

path Path to the target package root. Defaults to the current directory.
overwrite Logical. Overwrite the three template files (build-site.R, altdown.scss, quarto_website_static.yml) if already present in <path>/altdoc/? Default FALSE.

Details

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

# .gitignore
altdoc/freeze.rds
altdoc/pkgdown.yml
_quarto/*
!_quarto/_freeze/

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

These mirror what altdoc::setup_docs(tool = “quarto_website”) itself adds, plus altdoc/pkgdown.yml: altdoc::render_docs() rewrites that file with a fresh last_built timestamp on every build.

Value

Invisibly, the path to the created altdoc/ directory.

Examples

library("altdown")

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.scss"              "build-site.R"             
[3] "quarto_website_static.yml" "reference.yml"            
unlink(pkg, recursive = TRUE)