pub struct MethodDocBuilder<'a> {
class_name: &'a str,
method_name: &'a str,
type_ident: &'a Ident,
doc_tags: &'a [String],
name_prefix: Option<&'a str>,
r_name_override: Option<String>,
always_export: bool,
class_has_no_rd: bool,
params_as_details: bool,
r_params: Option<&'a str>,
suppress_params: bool,
match_arg_doc_placeholders: Option<&'a HashMap<String, String>>,
}Expand description
Builder for method-level roxygen documentation.
Generates roxygen tags for individual methods within a class. Methods share
the class’s @rdname so they appear on the same help page. The builder handles
@name formatting (with optional prefix like $ for Class$method style)
and respects @noRd inheritance from the parent class.
Fields§
§class_name: &'a strThe R class name (e.g., "Counter").
method_name: &'a strThe Rust method name (e.g., "inc").
type_ident: &'a IdentThe Rust type identifier, used in the @source annotation.
User-provided roxygen tags extracted from the method’s doc comments.
name_prefix: Option<&'a str>Optional separator between class name and method name in @name
(e.g., "$" produces @name Counter$inc).
r_name_override: Option<String>Override for the @name tag when the R function name differs from the Rust
method name (e.g., for standalone S3 methods like format.my_class).
always_export: boolWhen true, adds @export to the method (used for standalone S3/S4 generics).
Defaults to false because Class$method access does not need separate export.
class_has_no_rd: boolWhether the parent class has @noRd. When true, this method emits only
#' @noRd and skips all other documentation tags.
params_as_details: boolWhen true, convert @param tags into \describe{} blocks instead of
roxygen @param entries.
Used for env-class methods where roxygen cannot infer \usage from
Class$method <- function(). Without this, @param tags create
\arguments entries with no matching \usage, causing R CMD check
warnings (“Documented arguments not in \usage”).
r_params: Option<&'a str>Optional comma-separated R parameter string for auto-generating @param tags.
When set, any parameter not already documented gets @param name (undocumented).
suppress_params: boolWhen true, filter out @param tags from the doc_tags before pushing.
Used for S4/S7 instance methods where the method is defined via setMethod()
or S7::method() assignment, which roxygen2 doesn’t parse for \usage entries.
Including @param tags would create “Documented arguments not in \usage” warnings.
match_arg_doc_placeholders: Option<&'a HashMap<String, String>>Map of R-param-name → write-time doc placeholder for match_arg parameters.
When the auto-generated @param line would otherwise say (undocumented),
a match_arg’d param emits the placeholder instead, which the cdylib’s
write-time pass replaces with a rendered choice description (#210).
Implementations§
Source§impl<'a> MethodDocBuilder<'a>
impl<'a> MethodDocBuilder<'a>
Sourcepub fn new(
class_name: &'a str,
method_name: &'a str,
type_ident: &'a Ident,
doc_tags: &'a [String],
) -> Self
pub fn new( class_name: &'a str, method_name: &'a str, type_ident: &'a Ident, doc_tags: &'a [String], ) -> Self
Create a new MethodDocBuilder with default settings.
By default, always_export is false because methods accessed via Class$method
should not be exported directly – only the class env and standalone S3 methods
need @export.
Sourcepub fn with_match_arg_doc_placeholders(
self,
placeholders: &'a HashMap<String, String>,
) -> Self
pub fn with_match_arg_doc_placeholders( self, placeholders: &'a HashMap<String, String>, ) -> Self
Supply a map from R-param-name to a write-time doc placeholder for
match_arg’d params. When the auto-generated @param line would otherwise
say (undocumented), the placeholder is emitted instead and the cdylib
write pass rewrites it to a rendered choice description. See #210.
Sourcepub fn with_name_prefix(self, prefix: &'a str) -> Self
pub fn with_name_prefix(self, prefix: &'a str) -> Self
Set a prefix for the @name tag (e.g., “$” for “Class$method”).
Sourcepub fn with_r_name(self, r_name: String) -> Self
pub fn with_r_name(self, r_name: String) -> Self
Override the @name tag with a custom R function name.
Use this when the R function name differs from the Rust method name
(e.g., for standalone S3/S4/S7 static methods like s3counter_default_counter).
Sourcepub fn with_class_no_rd(self, class_has_no_rd: bool) -> Self
pub fn with_class_no_rd(self, class_has_no_rd: bool) -> Self
Set whether the parent class has @noRd.
When true, skips @name, @rdname, @source tags and adds @noRd instead.
Sourcepub fn with_params_as_details(self) -> Self
pub fn with_params_as_details(self) -> Self
Convert @param tags to inline \describe{} blocks instead of roxygen @param.
Used for env-class methods where roxygen can’t infer \usage from Class$method <- function().
Without this, @param tags create \arguments entries with no matching \usage,
causing R CMD check warnings (“Documented arguments not in \usage”).
Sourcepub fn with_r_params(self, params: &'a str) -> Self
pub fn with_r_params(self, params: &'a str) -> Self
Set the method’s formal parameter names (comma-separated R params string).
When set, auto-generates @param name (undocumented) for any parameter
not already covered by a user @param tag. Skips self, .ptr, and
... parameters.
Sourcepub fn with_suppress_params(self) -> Self
pub fn with_suppress_params(self) -> Self
Suppress @param tags from user doc comments.
Used for S4/S7 instance methods where the method is defined via setMethod()
or S7::method() assignment, which roxygen2 doesn’t parse for \usage entries.
Sourcepub fn build(&self) -> Vec<String>
pub fn build(&self) -> Vec<String>
Build the roxygen #' @tag lines for the method.
Returns a vector of strings, each a complete roxygen comment line. If the parent
class has @noRd, returns only ["#' @noRd"]. Otherwise generates @name,
@rdname, @source, and optionally @export tags, plus any user-provided tags.
Auto Trait Implementations§
impl<'a> Freeze for MethodDocBuilder<'a>
impl<'a> RefUnwindSafe for MethodDocBuilder<'a>
impl<'a> !Send for MethodDocBuilder<'a>
impl<'a> !Sync for MethodDocBuilder<'a>
impl<'a> Unpin for MethodDocBuilder<'a>
impl<'a> UnsafeUnpin for MethodDocBuilder<'a>
impl<'a> UnwindSafe for MethodDocBuilder<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)]const SIZE: usize = _
#[doc(hidden)]const SIZE: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGN: usize = _
#[doc(hidden)]const ALIGN: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGNMENT: Alignment = _
#[doc(hidden)]const ALIGNMENT: Alignment = _
ptr_alignment_type)Source§#[doc(hidden)]const IS_ZST: bool = _
#[doc(hidden)]const IS_ZST: bool = _
sized_type_properties)Source§#[doc(hidden)]const LAYOUT: Layout = _
#[doc(hidden)]const LAYOUT: Layout = _
sized_type_properties)Source§#[doc(hidden)]const MAX_SLICE_LEN: usize = _
#[doc(hidden)]const MAX_SLICE_LEN: usize = _
sized_type_properties)[Self]. Read moreLayout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 128 bytes