Skip to main content

MethodDocBuilder

Struct MethodDocBuilder 

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

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

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

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

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

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 self, .ptr, and ... parameters.

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 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> 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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: 128 bytes