| Title: | Generate Markdown Reference Documentation for R Packages |
|---|---|
| Description: | Generates plain Markdown reference documentation for any R package, installed or a local development source tree, optimized for rendering in the 'GitHub'/'Gitea' browser UI and for use as LLM context (e.g. 'Claude Code'). Reads Rd documentation via tools::Rd_db() (installed packages) or directly from man/*.Rd (development packages, no installation required) and renders one file per topic plus a navigable index. |
| Authors: | Peter Czerner [aut, cre] |
| Maintainer: | Peter Czerner <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1 |
| Built: | 2026-10-11 12:33:06 UTC |
| Source: | https://github.com/peterczerner/pkgmd |
Reads the Rd documentation of a package - either installed, or a local
development package that has not been installed - renders it as
Markdown, and writes one .md file per function into output_dir.
Also produces a README.md (index table of all functions) and a
_full_reference.md (every function in one file, meant to be injected
as LLM context, e.g. via @docs/reference/_full_reference.md in Claude
Code).
build_reference( package = ".", output_dir = NULL, overwrite = TRUE, include_private = TRUE )build_reference( package = ".", output_dir = NULL, overwrite = TRUE, include_private = TRUE )
package |
Name of an installed package, or a path to a local
package source directory. Defaults to |
output_dir |
Target directory for the generated |
overwrite |
If |
include_private |
If |
package accepts two kinds of input:
the name of an installed package, e.g. "dplyr" - Rd data is
read via tools::Rd_db();
a path to a local package source directory, e.g. "." or
"../myotherpkg" (detected by the presence of a DESCRIPTION file
at that path) - Rd data is read directly from man/*.Rd, falling
back to a live roxygen2::parse_package() parse if man/ is
missing or empty. This mode does not require the package to be
installed.
Invisibly, the path to output_dir.
## Not run: # Installed package: pkgmd::build_reference("dplyr", output_dir = "docs/reference") # Development package, not installed - "." and "md-docs" are both # defaults, so this is equivalent to just build_reference(): pkgmd::build_reference(".", output_dir = "md-docs") # Public API only, no internal helpers: pkgmd::build_reference("dplyr", output_dir = "docs/reference", include_private = FALSE) ## End(Not run)## Not run: # Installed package: pkgmd::build_reference("dplyr", output_dir = "docs/reference") # Development package, not installed - "." and "md-docs" are both # defaults, so this is equivalent to just build_reference(): pkgmd::build_reference(".", output_dir = "md-docs") # Public API only, no internal helpers: pkgmd::build_reference("dplyr", output_dir = "docs/reference", include_private = FALSE) ## End(Not run)
Returns the same Markdown content that build_reference() writes to
_full_reference.md - every topic rendered and concatenated into one
string - without writing anything to disk. Meant for programmatic
consumption, e.g. an LLM agent that wants a package's complete
reference injected directly into its context in one call.
get_documentation(package = ".", include_private = FALSE)get_documentation(package = ".", include_private = FALSE)
package |
As in |
include_private |
If |
A single string: the package's full reference documentation in Markdown.
## Not run: # Installed package: docs <- pkgmd::get_documentation("dplyr") # Development package, not installed: docs <- pkgmd::get_documentation(".") ## End(Not run)## Not run: # Installed package: docs <- pkgmd::get_documentation("dplyr") # Development package, not installed: docs <- pkgmd::get_documentation(".") ## End(Not run)