pub struct MethodDocBuilder<'a> {Show 13 fields
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,
choice_param_docs: Option<&'a HashMap<String, String>>,
source_method: Option<&'a Ident>,
}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, with the choice text of undocumented choice
parameters as extra items (describe_params_lines).
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)
(in params_as_details mode only a choice parameter gets an item).
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.
choice_param_docs: Option<&'a HashMap<String, String>>Map of R-param-name → auto-generated @param text for choice
parameters (choice_param_doc_map).
When the auto-generated @param line would otherwise say (undocumented),
a match_arg param emits its placeholder instead, which the wrapper
writer replaces with a rendered choice description (#210), and
a choices(...) param its literal One of ... line.
source_method: Option<&'a Ident>The Rust method named by the @source Generated by miniextendr from Type::method`` line (with_source_method),
else method_name.
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_source_method(self, method: &'a Ident) -> Self
pub fn with_source_method(self, method: &'a Ident) -> Self
Name method in the @source provenance line: the Rust method behind
an R name that differs from it (a constructor’s new, an r_name, a
generic).
Sourcepub fn with_choice_param_docs(self, docs: &'a HashMap<String, String>) -> Self
pub fn with_choice_param_docs(self, docs: &'a HashMap<String, String>) -> Self
Supply the R-param-name → @param text map of the method’s choice
params (choice_param_doc_map). When the auto-generated @param
line would otherwise say (undocumented), that text is emitted instead
(a match_arg placeholder is rewritten by the wrapper writer, #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”). With
with_r_params and
with_choice_param_docs, an undocumented
choice parameter gets a list item with its choice text; no parameter
gets an (undocumented) filler.
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 .mx_self, .ptr, and
... parameters. Generates nothing when the method’s own tags take the
arguments from another topic (@rdname, @describeIn,
@inheritParams; see roxygen::params_documented_elsewhere).
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 roxygen comment lines, with generated member defaults marked for
the class assembler (CLASS_MEMBER_DEFAULT_PREFIX). If the parent
class has @noRd, returns only ["#' @noRd"]. Otherwise generates @name,
@rdname, @source, and optionally @export tags, plus any user-provided tags.
A method that joins an author topic (@rdname other, @describeIn other)
gets no @name / @rdname next to @describeIn, and sorts after the
topic’s own block (roxygen::ORDER_AFTER_TOPIC_BLOCKS).
Auto Trait Implementations§
impl<'a> !Send for MethodDocBuilder<'a>
impl<'a> !Sync for MethodDocBuilder<'a>
impl<'a> Freeze for MethodDocBuilder<'a>
impl<'a> RefUnwindSafe 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> SizeHint for Twhere
T: ?Sized,
impl<T> SizeHint for Twhere
T: ?Sized,
Source§default fn lower_bound(&self) -> usize
default fn lower_bound(&self) -> usize
core_io_internals)[u8; 12] could return any value between 0 and
12 inclusively as a correct implementation. Read moreSource§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: 136 bytes