Skip to main content

Module r_wrappers

Module r_wrappers 

Source
Expand description

R wrapper generation for trait methods across all class systems.

Each class system (Env, S3, S4, S7, R6, Vctrs) has its own generator that produces R code strings for instance methods, static methods, and associated constants. The top-level generate_trait_r_wrapper dispatches to the appropriate generator and applies post-processing for export/documentation control.

Structs§

TraitWrapperOpts 🔒
Options controlling export visibility and documentation for trait R wrapper generation.

Constants§

PAGE_TAGS 🔒
The author tags of a trait-impl method that its own wrapper block forwards besides the @param lines: the tags that decide the method’s page and where its arguments are documented. @describeIn / @rdname route the block, @name names its topic, @order sorts it, and @inheritParams / @inherit / @inheritDotParams fill its arguments. Env trait methods and the namespace statics of S3, vctrs and S7 forward every other tag but @title and a bare @export too (forwarded_body_tag); S4 statics get @param lines (param_doc_tags).

Functions§

check_trait_method_formals 🔒
Check the R formals of every trait method (check_r_formals). Every dispatching class system defaults an instance method’s receiver to x. S3/S4 existing-generic overrides can select another receiver. S7 shortcuts and Env/R6 trait methods use the injected receiver .mx_self, which cannot be spelled by a Rust parameter.
describes_in 🔒
Whether the method-level @describeIn lists the method’s own block in its destination’s “Functions” section.
finish_instance_body 🔒
Close an instance-method body (#1213).
forwarded_body_tag 🔒
Whether the body of a block without \usage (an env trait method, a Type$Trait$method static of S3 and vctrs, an attr(Type, "Trait")$method static of S7) forwards the author tag tag: every tag but the PAGE_TAGS, which own_block_page_lines forwards, @title, which the structural split-page title owns, and a bare @export, which would export the member itself (forwarded_member_tag). The @param lines become items of the block’s \describe{} list.
generate_trait_env_r_wrapper 🔒
Generate Env-style R wrapper code for trait methods.
generate_trait_r6_r_wrapper 🔒
Generate R6-style R wrapper code.
generate_trait_r_wrapper 🔒
Generate R wrapper code for trait methods and consts, dispatching by class system.
generate_trait_s3_r_wrapper 🔒
Generate S3-style R wrapper code (generic + method.Type).
generate_trait_s4_r_wrapper 🔒
Generate S4-style R wrapper code.
generate_trait_s7_r_wrapper 🔒
Generate S7-style R wrapper code.
joins_author_topic 🔒
Whether the method’s page is an author topic other than the type page (@describeIn, or an @rdname naming another page). The topic’s own block documents that page, so the method’s blocks sort after it (@order NaN) and leave the structural @param lines (x, ..., self) and generated prose to it.
method_page 🔒
The page a trait method’s own block lands on, and with it the companion block that must share it (the S3 generic block, named after the method): the @describeIn destination, the method-level @rdname, else the type’s shared page. Generics of S4 / S7 and consts always use the type page.
namespace_member_body_lines 🔒
The documentation body of a block without \usage (see forwarded_body_tag), documented like an env inherent method: the forwarded author tags, then one \describe{} list with the author’s @param items and the choice text of the parameters they leave undocumented (describe_params_lines). label is the block’s topic name, used in the list’s lead-in. Empty for a method with no doc comment and no choice parameter.
own_block_page_lines 🔒
The page lines of a trait method’s own wrapper block, as MethodDocBuilder writes an inherent method’s (#1590):
param_doc_tags 🔒
The @param tags of a block that documents the method’s arguments in a \usage (an S3 / vctrs instance method, an S4 static): the author’s @param lines, then one per formal of ctx.params they leave undocumented, with its choice text for a choice parameter and (undocumented) otherwise. A method whose arguments another block documents (an author topic, @inheritParams) gets no generated tag (#1590).
param_tags 🔒
The @param lines of the method’s doc comment.
params_documented_elsewhere 🔒
Whether the method’s arguments are documented by another block: it joins an author topic, or inherits them (@inheritParams, @inherit). The generated (undocumented) fillers are left out then.
push_param_tags 🔒
Push the method’s @param lines, each continuation line with its own #' lead.
reject_unsupported_describe_in 🔒
Reject a method-level @describeIn that roxygen2 cannot honour on the trait wrapper (#1590), the rule ParsedImpl::reject_unsupported_describe_in applies to inherent methods.