Maëlle Salmon (rOpenSci, cynkra)
What I learned through use cases.
Through roxygen2::roxygenize()/devtools::document():
Parsing of code decorators (tags) like @details
Generation of manual pages and NAMESPACE.
It is extensible.
It has been extended.
devtag by Antoine Fabri (cynkra)
Document internal functions with roxygen2 tags and…
roxygen2’s @noRd😭
roxygen2’s @keywords internal 😕
devtag’s @dev Rd only for developers! .Rbuildignore 🎉
srr by Mark Padgham (rOpenSci) to document compliance with statistical software standards.
Example: eDNAjoint by Abigail G. Keller
roxytest by Mikkel Meyer Andersen.
Inline tests with roxygen2 using testthat or tinytest.
“A big thanks goes to Mikkel Meyer Andersen for starting on the vignette and motivating me to make the extension process much more pleasant.” Hadley Wickham, roxygen2 7.0.0

?ellmer::chat_openai without having any OpenAI account.
✨ better docs for little effort ✨
I only want to create custom sections in Rd files. Easy, right?! 🥺
There are two primary ways to extend roxygen2:
- Add a new tag that generates a new top-level section in .Rd files.
- Add a new roclet that does anything you like.
Person with an intense gaze explaining something using a corkboard covered by paper pieces and yarn connecting them
roxygenize() doesLoads packages you tell it to load.
Parses all package R files, using available tags.
Finds the roclets you tell it to run. Rd roclet, NAMESPACE roclet, your roclet…
Runs the different methods of all those roclets. Preprocess, process, output.
parsing: If you define how to parse a tag roxygen2 will use it!! 🤯
roclet (S3 vessel for code!): roxygen2 will run your code!! 🤯
the tag in use: #' @cdocs igraph_is_acyclic
the Rd section rendered on the pkgdown website ✨
roxy_tag_parse()method.roxygen2::tag_words()and friends. If absent: warning, tag ignored by parsing.
roxy_tag_rd()method.roxygen2::rd_section("cdocs", x$val)If absent: tag ignored by the Rd making.
- [If custom section]
format()method. Rd string creation.
Tag-creator package: Export the methods.
igraph.r2cdocs: Imports roxygen2 + @export
ggplot2 (@aesthetics): Suggests roxygen2 + rlang::on_load() + vctrs::s3_register()
User package: Declare the use of the tag-creator package in DESCRIPTION.
packages
: packages to load that implement new tags.
https://roxygen2.r-lib.org/reference/load_options.html#possible-options
loadNamespace()
Informally, obviously 😸
Still focussed on Rd sections but…
Less work please!
Get link to C docs without adding the @cdocs tag.
For each manual page…
Get the aliases.
For each alias, get the call tree ({treesitter} FTW), extract names of C functions.
Create section with C links.
The challenge: An Rd section without tag!
https://github.com/gaborcsardi/roxygenlabs/
💡 Extend the Rd roclet
Use that roclet in lieu of the Rd roclet.
Roclet creator package: Export the roclet and its methods.
User package: Roxygen2 option to be stored in DESCRIPTION
roclets
: giving names of roclets to run.
Roxygen field (to be retired?), maybe Config/Needs or Suggests field.
Documentation
Function like use_devtag(), relying on {desc}
Better docs with less manual work.
New tag. From a string to a templated section. Defined by methods. packages roxygen2 option.
New roclet extending the Rd roclet. From information in the topic to a templated section. Defined by methods. roclets roxygen2 option.
Anything a tiny bit fancy requires defining a roclet.

https://github.com/posit-dev/plumber2/
api() instead of roxygenize()/document()
to get good docs: read the roxygen2 docs website.
to repeat yourself less for Rd: create a custom tag.
to repeat yourself even less for Rd: extend the Rd roclet.
to do anything for packages: create a custom roclet.
to use code decorators outside of packages: use the parsing like plumber2.
roxygenize()Extending roxygen2 is possible and useful!
Documentation still patchy or a bit hidden.
subclass parameter of roclet()Thank you!! 🙏