Skip to main content

MethodDocBuilder

Struct MethodDocBuilder 

Source
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 str

The R class name (e.g., "Counter").

§method_name: &'a str

The Rust method name (e.g., "inc").

§type_ident: &'a Ident

The Rust type identifier, used in the @source annotation.

§doc_tags: &'a [String]

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: bool

When 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: bool

Whether the parent class has @noRd. When true, this method emits only #' @noRd and skips all other documentation tags.

§params_as_details: bool

When 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: bool

When 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>

Source

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.

Source

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).

Source

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).

Source

pub fn with_name_prefix(self, prefix: &'a str) -> Self

Set a prefix for the @name tag (e.g., “$” for “Class$method”).

Source

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).

Source

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.

Source

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.

Source

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).

Source

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.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> SizeHint for T
where T: ?Sized,

Source§

default fn lower_bound(&self) -> usize

🔬This is a nightly-only experimental API. (core_io_internals)
Returns a lower bound on the number of elements this container-like item contains. For example, an array [u8; 12] could return any value between 0 and 12 inclusively as a correct implementation. Read more
Source§

default fn upper_bound(&self) -> Option<usize>

🔬This is a nightly-only experimental API. (core_io_internals)
Returns an upper bound on the number of elements this container-like item contains if it can be determined, otherwise None. Read more
Source§

final fn size_hint(&self) -> (usize, Option<usize>)

🔬This is a nightly-only experimental API. (core_io_internals)
Returns an estimate for the number of elements this container like type contains. Read more
Source§

impl<T> SizedTypeProperties for T

Source§

#[doc(hidden)]
const SIZE: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)]
const ALIGN: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)]
const ALIGNMENT: Alignment = _

🔬This is a nightly-only experimental API. (ptr_alignment_type)
Source§

#[doc(hidden)]
const IS_ZST: bool = _

🔬This is a nightly-only experimental API. (sized_type_properties)
true if this type requires no storage. false if its size is greater than zero. Read more
Source§

#[doc(hidden)]
const LAYOUT: Layout = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)]
const MAX_SLICE_LEN: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
The largest safe length for a [Self]. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

Layout§

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