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_MARKERline: the wrapper writer puts there the doc tags of every impl block of the type (ClassDocBuilder::docs) @paramfor 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 strThe R-visible class name (e.g., "Counter").
type_ident: &'a IdentThe Rust type identifier, used in the @source annotation.
User-provided roxygen tags extracted from doc comments.
class_system_label: &'static strHuman-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: boolWhen true, adds @keywords internal and suppresses @export.
Set by #[miniextendr(internal)].
attr_noexport: boolWhen 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>
impl<'a> ClassDocBuilder<'a>
Sourcepub fn new(
class_name: &'a str,
type_ident: &'a Ident,
doc_tags: &'a [String],
class_system_label: &'static str,
) -> Self
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.
Sourcepub fn with_ctor_params(
self,
params: &'a str,
choice_docs: &'a HashMap<String, String>,
) -> Self
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>()).
Sourcepub fn with_imports(self, imports: impl Into<String>) -> Self
pub fn with_imports(self, imports: impl Into<String>) -> Self
Set R package imports (e.g., “@importFrom R6 R6Class”).
Sourcepub fn with_export_control(self, internal: bool, noexport: bool) -> Self
pub fn with_export_control(self, internal: bool, noexport: bool) -> Self
Set attribute-level internal/noexport flags from ParsedImpl.
Sourcepub fn docs(&self) -> Vec<String>
pub fn docs(&self) -> Vec<String>
The user-provided doc tags as roxygen lines, for
ClassWrapper::class_docs.
Sourcepub fn build(&self) -> Vec<String>
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> 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: 112 bytes