Skip to main content

ClassDocBuilder

Struct ClassDocBuilder 

Source
pub struct ClassDocBuilder<'a> {
    class_name: &'a str,
    type_ident: &'a Ident,
    doc_tags: &'a [String],
    class_system_label: &'static str,
    imports: Option<String>,
    attr_internal: bool,
    attr_noexport: bool,
    ctor_params: Option<(&'a str, &'a HashMap<String, String>)>,
}
Expand description

Builder for class-level roxygen documentation header.

Generates the common roxygen tags that appear at the start of each class definition:

  • @title (unless user provided)
  • @name (unless user provided)
  • @rdname (unless user provided)
  • User-provided doc tags, as the CLASS_DOCS_MARKER line: the wrapper writer puts there the doc tags of every impl block of the type (ClassDocBuilder::docs)
  • @param for the constructor formals the tags leave undocumented, when set (with_ctor_params; S3 and vctrs, whose class block is the constructor’s block)
  • @source Generated by miniextendr...
  • Class-system-specific imports
  • @export (unless user provided, @noRd, or internal/noexport flags)

The generated @title, @name, @rdname, @param and @export lines are class_defaults, which a tag on another impl block replaces.

Fields§

§class_name: &'a str

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

§type_ident: &'a Ident

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

§doc_tags: &'a [String]

User-provided roxygen tags extracted from doc comments.

§class_system_label: &'static str

Human-readable label for the class system (e.g., "R6", "S3"), used in the auto-generated @title. Empty for Env classes, whose title is plain "<Class> Class".

§imports: Option<String>

Optional @importFrom tag for class-system-specific R packages (e.g., "@importFrom R6 R6Class").

§attr_internal: bool

When true, adds @keywords internal and suppresses @export. Set by #[miniextendr(internal)].

§attr_noexport: bool

When true, suppresses @export but does not add @keywords internal. Set by #[miniextendr(noexport)].

§ctor_params: Option<(&'a str, &'a HashMap<String, String>)>

The constructor’s R formals and its choice-parameter @param text (choice_param_doc_map), for classes whose class block documents the constructor (S3, vctrs). See ClassDocBuilder::with_ctor_params.

Implementations§

Source§

impl<'a> ClassDocBuilder<'a>

Source

pub fn new( class_name: &'a str, type_ident: &'a Ident, doc_tags: &'a [String], class_system_label: &'static str, ) -> Self

Create a new ClassDocBuilder with the given class metadata.

By default, @export is included unless suppressed by user tags or the with_export_control method.

Source

pub fn with_ctor_params( self, params: &'a str, choice_docs: &'a HashMap<String, String>, ) -> Self

Document the constructor’s formals on the class block: each formal the doc tags leave undocumented gets @param name <choice text> for a choice parameter and @param name (undocumented) otherwise, right after the doc tags. Nothing under @noRd / plain noexport, or when the tags take the arguments from another topic (@rdname other, @inheritParams). For generators whose class block is the constructor’s block (S3 new_<class>(), vctrs new_<class>()).

Source

pub fn with_imports(self, imports: impl Into<String>) -> Self

Set R package imports (e.g., “@importFrom R6 R6Class”).

Source

pub fn with_export_control(self, internal: bool, noexport: bool) -> Self

Set attribute-level internal/noexport flags from ParsedImpl.

Source

pub fn docs(&self) -> Vec<String>

The user-provided doc tags as roxygen lines, for ClassWrapper::class_docs.

Source

pub fn build(&self) -> Vec<String>

Build the roxygen #' @tag lines for the class header.

Returns a vector of strings, each a complete roxygen comment line (e.g., "#' @title ..."), a class_default or the CLASS_DOCS_MARKER. Auto-generates @title, @name, and @rdname if not provided by the user, and respects @noRd to suppress all documentation output.

Auto Trait Implementations§

§

impl<'a> !Send for ClassDocBuilder<'a>

§

impl<'a> !Sync for ClassDocBuilder<'a>

§

impl<'a> Freeze for ClassDocBuilder<'a>

§

impl<'a> RefUnwindSafe for ClassDocBuilder<'a>

§

impl<'a> Unpin for ClassDocBuilder<'a>

§

impl<'a> UnsafeUnpin for ClassDocBuilder<'a>

§

impl<'a> UnwindSafe for ClassDocBuilder<'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: 112 bytes