Skip to main content

Module roxygen

Module roxygen 

Source
Expand description

Roxygen tag extraction and processing for R wrapper generation.

This module extracts roxygen2-style tags (e.g., @param, @examples) from Rust doc comments and propagates them to generated R wrapper code.

Β§Usage

In Rust doc comments, use roxygen2 tags:

β“˜
/// @param x A numeric input.
/// @return The squared value.
/// @examples
/// square(4)
#[miniextendr]
pub fn square(x: f64) -> f64 { x * x }

Β§R Package Configuration

For roxygen2 to process multiline tags correctly, add this to your DESCRIPTION file:

Roxygen: list(markdown = TRUE)

ConstantsΒ§

METHOD_ONLY_TAGS πŸ”’
Roxygen tags that only make sense on individual methods, not on impl blocks.
METHOD_ONLY_TAGS_R6 πŸ”’
Tags stripped from impl-block docs for R6 classes β€” same as METHOD_ONLY_TAGS minus "param", since roxygen2 8.0.0 inherits class-level @param tags into all R6 methods and strips them from the rendered method entries automatically. This means /// @param breed … on an R6 impl block is valid and intentional, not a misplaced method-only tag. Keeping them avoids both the compile warning and the resulting (no documentation available) placeholder on subclass ctors.
MULTILINE_TAGS πŸ”’
Tags that allow multi-line content (continuation lines appended). All other tags are treated as single-line.

FunctionsΒ§

class_source_tag πŸ”’
Build a roxygen @source traceability line for a class definition.
doc_conflict_warnings πŸ”’
Check for conflicts between explicit @title/@description tags and implicit values.
explicit_roxygen_tags_from_attrs πŸ”’
Parse only the author-written @tag lines from doc attributes β€” no leading-prose promotion.
extract_param_names πŸ”’
Extract the set of parameter names declared via @param in a list of roxygen tags.
find_tag_value πŸ”’
Find the value of a specific roxygen tag (e.g., β€œtitle” for @title ...).
formal_name πŸ”’
Extract the R parameter name from a single formal (e.g. mode = c("a","b") β†’ mode). Pair with split_r_formals, never a raw split(',').
format_roxygen_tags πŸ”’
Render roxygen tag lines as β€œ#’ …” comment lines.
has_roxygen_tag πŸ”’
Return true if the tag list contains a specific roxygen tag.
implicit_description_from_attrs πŸ”’
Extract the implicit description from doc attributes (second paragraph).
implicit_title_from_attrs πŸ”’
Extract the implicit title from doc attributes (first sentence, up to first . or newline).
is_multiline_tag πŸ”’
Check if a tag name supports multi-line content.
leading_prose_from_attrs πŸ”’
Collect the leading prose of a doc comment (all paragraphs before the first @tag) as roxygen @description text, with rustdoc intra-doc links neutralized.
method_source_tag πŸ”’
Build a roxygen @source traceability line for a class method.
normalize_for_comparison πŸ”’
Normalize text for comparison: lowercase, collapse whitespace, strip trailing punctuation.
push_roxygen_tags πŸ”’
Push roxygen tag lines into a vector of R wrapper lines.
push_roxygen_tags_str πŸ”’
Like push_roxygen_tags but takes &[&str] for filtered tag slices.
roxygen_tag_name πŸ”’
Extract the tag name from a roxygen line (everything between @ and the first whitespace character). Returns None for lines that don’t start with a tag.
roxygen_tags_from_attrs πŸ”’
Extract roxygen tag lines (starting with β€˜@’) from Rust doc attributes.
roxygen_tags_from_attrs_for_r6_method πŸ”’
Extract roxygen tags for an impl-block method.
roxygen_tags_from_attrs_impl πŸ”’
Core implementation of roxygen tag extraction from #[doc = "..."] attributes.
sanitize_roxygen_links πŸ”’
Neutralize rustdoc intra-doc link syntax so prose is valid roxygen2 markdown.
split_r_formals πŸ”’
Split an R formals/argument string on top-level commas only.
strip_method_tags πŸ”’
Filter out method-specific roxygen tags from impl-block-level docs and emit compile warnings for each stripped tag.
strip_method_tags_r6 πŸ”’
Like strip_method_tags but for R6 impl blocks.
strip_roxygen_from_attrs πŸ”’
Strip roxygen tag lines from doc attributes, keeping only regular documentation.
tag_names πŸ”’
Extract the set of tag names from a list of roxygen tag strings.