Add hover tooltips to an altdoc or pkgdown site’s reference links
Description
Run after you build docs with altdoc::render_docs() or pkgdown::build_site(). Reads the package’s own man/*.Rd files (see build_topic_index()) and rewrites every docs/**/*.html file, attaching a hover tooltip to each reference link that names a documented object in this package. Everything else is left untouched.
Usage
add_tooltips(
path = ".",
docs_dir = NULL,
site = c("auto", "altdoc", "pkgdown"),
quiet = FALSE
)
Arguments
path
|
Path to the package root. |
docs_dir
|
Path to the built site. Defaults to file.path(path, “docs”).
|
site
|
One of “auto” (default), “altdoc”, or “pkgdown”. “auto” detects the site type from docs_dir’s layout: a reference/ subdirectory means pkgdown, a man/ subdirectory means altdoc.
|
quiet
|
Logical. Suppress progress messages. |
Details
On an altdoc site, downlit can’t resolve the package’s own (local, unpublished) functions, so reftip also relinks each reference straight to docs/man/<topic>.html. On a pkgdown site, downlit already resolves these correctly (it builds against the installed local package), so reftip leaves the existing link alone and only attaches the tooltip; it builds a link itself only for a name downlit left unlinked (e.g. an S3 method called by name).
Idempotent: a file that already carries reftip’s marker comment is skipped, so it’s safe to rerun after a fresh build.
Value
Invisibly, a list with files (how many HTML files were touched) and links (how many reference links got a tooltip).