pub struct RdDocument { /* private fields */ }Expand description
A complete parsed Rd document.
nodes are the top-level children of the parsed Rd object: a mix of
section-tagged nodes (\name, \title, \description, …) and the
whitespace TEXT leaves R’s parser leaves between them. Nothing is
filtered out at this layer – see the crate-level documentation for the
losslessness rationale.
Implementations§
Source§impl RdDocument
impl RdDocument
Source§impl RdDocument
impl RdDocument
Sourcepub fn title(&self) -> Option<&[RdNode]>
pub fn title(&self) -> Option<&[RdNode]>
Lossy: returns the first top-level \title{...}’s children, if any.
See Self::inspect_title for diagnostics.
“First-wins”: if \title appears more than once at the top level
(malformed input), only the first occurrence is returned. Only
RdNode::Tagged top-level nodes are considered – see the
module-level documentation for why a top-level RdNode::Raw node
whose tag string happens to be "\\title" is not matched.
Sourcepub fn description(&self) -> Option<&[RdNode]>
pub fn description(&self) -> Option<&[RdNode]>
Lossy: returns the first top-level \description{...}’s children, if any.
See Self::inspect_description for diagnostics.
Same first-wins-on-duplicates and Tagged-only semantics as
RdDocument::title.
Sourcepub fn usage(&self) -> Option<&[RdNode]>
pub fn usage(&self) -> Option<&[RdNode]>
Lossy: returns the first top-level \usage{...}’s children, if any.
See Self::inspect_usage for diagnostics.
Same first-wins-on-duplicates and Tagged-only semantics as
RdDocument::title.
Sourcepub fn value(&self) -> Option<&[RdNode]>
pub fn value(&self) -> Option<&[RdNode]>
Lossy: returns the first top-level \value{...}’s children, if any.
See Self::inspect_value for diagnostics.
Same first-wins-on-duplicates and Tagged-only semantics as
RdDocument::title.
Sourcepub fn name(&self) -> Option<&[RdNode]>
pub fn name(&self) -> Option<&[RdNode]>
Lossy: returns the first top-level \name{...}’s children, if any.
See Self::inspect_name for diagnostics. First-wins on duplicates.
Sourcepub fn details(&self) -> Option<&[RdNode]>
pub fn details(&self) -> Option<&[RdNode]>
Lossy: returns the first top-level \details{...}’s children, if any.
See Self::inspect_details for diagnostics. First-wins on duplicates.
Sourcepub fn note(&self) -> Option<&[RdNode]>
pub fn note(&self) -> Option<&[RdNode]>
Lossy: returns the first top-level \note{...}’s children, if any.
See Self::inspect_note for diagnostics. First-wins on duplicates.
Lossy: returns the first top-level \author{...}’s children, if any.
See Self::inspect_author for diagnostics. First-wins on duplicates.
Sourcepub fn references(&self) -> Option<&[RdNode]>
pub fn references(&self) -> Option<&[RdNode]>
Lossy: returns the first top-level \references{...}’s children, if any.
See Self::inspect_references for diagnostics. First-wins on duplicates.
Sourcepub fn see_also(&self) -> Option<&[RdNode]>
pub fn see_also(&self) -> Option<&[RdNode]>
Lossy: returns the first top-level \seealso{...}’s children, if any.
See Self::inspect_see_also for diagnostics. First-wins on duplicates.
Sourcepub fn examples(&self) -> Option<&[RdNode]>
pub fn examples(&self) -> Option<&[RdNode]>
Lossy: returns the first top-level \examples{...}’s children, if any.
See Self::inspect_examples for diagnostics. First-wins on duplicates.
Sourcepub fn format(&self) -> Option<&[RdNode]>
pub fn format(&self) -> Option<&[RdNode]>
Lossy: returns the first top-level \format{...}’s children, if any.
See Self::inspect_format for diagnostics. First-wins on duplicates.
Sourcepub fn source(&self) -> Option<&[RdNode]>
pub fn source(&self) -> Option<&[RdNode]>
Lossy: returns the first top-level \source{...}’s children, if any.
See Self::inspect_source for diagnostics. First-wins on duplicates.
Sourcepub fn encoding(&self) -> Option<&[RdNode]>
pub fn encoding(&self) -> Option<&[RdNode]>
Lossy: returns the first top-level \encoding{...}’s children, if any.
See Self::inspect_encoding for diagnostics. First-wins on duplicates.
Sourcepub fn doc_type(&self) -> Option<&[RdNode]>
pub fn doc_type(&self) -> Option<&[RdNode]>
Lossy: returns the first top-level \docType{...}’s children, if any.
See Self::inspect_doc_type for diagnostics. First-wins on duplicates.
Sourcepub fn rd_version(&self) -> Option<&[RdNode]>
pub fn rd_version(&self) -> Option<&[RdNode]>
Lossy: returns the first top-level \Rdversion{...}’s children, if any.
See Self::inspect_rd_version for diagnostics. First-wins on duplicates.
Sourcepub fn synopsis(&self) -> Option<&[RdNode]>
pub fn synopsis(&self) -> Option<&[RdNode]>
Lossy: returns the first top-level \synopsis{...}’s children, if any.
See Self::inspect_synopsis for diagnostics. First-wins on duplicates.
Sourcepub fn aliases(&self) -> impl Iterator<Item = String> + '_
pub fn aliases(&self) -> impl Iterator<Item = String> + '_
Lossy: iterates the current topic’s \alias{...} declarations, in source
order, yielding each alias’s text_contents (no splitting, no
trimming – an alias with empty children yields an empty string).
This reads the topic’s own \alias markup, i.e. the alias names
this specific Rd document declares for itself. It is unrelated to a
package-wide help/aliases.rds index (as read by e.g.
rd-helpdb’s PackageHelpDb::aliases/resolve_alias), which maps
every alias in a package to the topic file that documents it.
Only top-level RdNode::Tagged nodes are considered – see the
module-level documentation for why a top-level RdNode::Raw node
whose tag string happens to be "\\alias" is not matched.
Sourcepub fn keywords(&self) -> impl Iterator<Item = String> + '_
pub fn keywords(&self) -> impl Iterator<Item = String> + '_
Lossy: iterates top-level \keyword{...} declarations in source order.
Sourcepub fn concepts(&self) -> impl Iterator<Item = String> + '_
pub fn concepts(&self) -> impl Iterator<Item = String> + '_
Lossy: iterates top-level \concept{...} declarations in source order.
Sourcepub fn sections(&self) -> impl Iterator<Item = RdSection<'_>>
pub fn sections(&self) -> impl Iterator<Item = RdSection<'_>>
Lossy: iterates the document’s custom \section{title}{body} nodes, in
source order.
This is distinct from the standard, fixed-vocabulary sections
(\description, \value, \details, …), which are read
individually (see RdDocument::title, RdDocument::description,
etc.). It only recognizes custom \section{...}{...} markup
(RdTag::Section).
A top-level node is recognized as a section only when it is a
Tagged node with RdTag::Section, no option, and
exactly two RdNode::Group children (the title/body positional-
argument groups the \section macro lowers to). Anything else is
silently skipped rather than erroring.
For nested \subsection traversal, see Self::section_tree.
Sourcepub fn arguments(&self) -> impl Iterator<Item = RdArgument<'_>>
pub fn arguments(&self) -> impl Iterator<Item = RdArgument<'_>>
Lossy: iterates the \item{name}{description} entries of the first
top-level \arguments{...} node, in source order.
Only the FIRST top-level Tagged node with RdTag::Arguments
node is considered (first-wins on duplicates, like
RdDocument::title); its DIRECT children are then scanned –
nested \arguments are not (there is no such thing in valid Rd,
but this function makes no attempt to look for one either way).
A direct child yields an RdArgument only when it matches
a Tagged node with RdTag::Item, no option, and the given children where
children has exactly two RdNode::Group children (the
name/description positional-argument groups the two-argument form of
\item lowers to). Everything else is
silently skipped: the whitespace TEXT leaves between \items,
an \item[label] with an option (the zero/one-argument
\itemize/\enumerate form, not the two-argument
\arguments/\describe form), an \item with the wrong number of
children, and any other non-\item markup. This is a total
function – it never errors, it just yields fewer items than the
source \arguments block might structurally contain.
If \arguments itself isn’t found as a top-level Tagged node
(see the module-level documentation on why Raw is never
interpreted), this yields no items.
Sourcepub fn inspect_title(&self) -> Result<Option<&[RdNode]>, RdShapeError>
pub fn inspect_title(&self) -> Result<Option<&[RdNode]>, RdShapeError>
Strict counterpart to the lossy Self::title accessor.
Sourcepub fn inspect_description(&self) -> Result<Option<&[RdNode]>, RdShapeError>
pub fn inspect_description(&self) -> Result<Option<&[RdNode]>, RdShapeError>
Strict counterpart to the lossy Self::description accessor.
Sourcepub fn inspect_usage(&self) -> Result<Option<&[RdNode]>, RdShapeError>
pub fn inspect_usage(&self) -> Result<Option<&[RdNode]>, RdShapeError>
Strict counterpart to the lossy Self::usage accessor.
Sourcepub fn inspect_value(&self) -> Result<Option<&[RdNode]>, RdShapeError>
pub fn inspect_value(&self) -> Result<Option<&[RdNode]>, RdShapeError>
Strict counterpart to the lossy Self::value accessor.
Sourcepub fn inspect_name(&self) -> Result<Option<&[RdNode]>, RdShapeError>
pub fn inspect_name(&self) -> Result<Option<&[RdNode]>, RdShapeError>
Strict counterpart to the lossy Self::name accessor.
Sourcepub fn inspect_details(&self) -> Result<Option<&[RdNode]>, RdShapeError>
pub fn inspect_details(&self) -> Result<Option<&[RdNode]>, RdShapeError>
Strict counterpart to the lossy Self::details accessor.
Sourcepub fn inspect_note(&self) -> Result<Option<&[RdNode]>, RdShapeError>
pub fn inspect_note(&self) -> Result<Option<&[RdNode]>, RdShapeError>
Strict counterpart to the lossy Self::note accessor.
Strict counterpart to the lossy Self::author accessor.
Sourcepub fn inspect_references(&self) -> Result<Option<&[RdNode]>, RdShapeError>
pub fn inspect_references(&self) -> Result<Option<&[RdNode]>, RdShapeError>
Strict counterpart to the lossy Self::references accessor.
Sourcepub fn inspect_see_also(&self) -> Result<Option<&[RdNode]>, RdShapeError>
pub fn inspect_see_also(&self) -> Result<Option<&[RdNode]>, RdShapeError>
Strict counterpart to the lossy Self::see_also accessor.
Sourcepub fn inspect_examples(&self) -> Result<Option<&[RdNode]>, RdShapeError>
pub fn inspect_examples(&self) -> Result<Option<&[RdNode]>, RdShapeError>
Strict counterpart to the lossy Self::examples accessor.
Sourcepub fn inspect_format(&self) -> Result<Option<&[RdNode]>, RdShapeError>
pub fn inspect_format(&self) -> Result<Option<&[RdNode]>, RdShapeError>
Strict counterpart to the lossy Self::format accessor.
Sourcepub fn inspect_source(&self) -> Result<Option<&[RdNode]>, RdShapeError>
pub fn inspect_source(&self) -> Result<Option<&[RdNode]>, RdShapeError>
Strict counterpart to the lossy Self::source accessor.
Sourcepub fn inspect_encoding(&self) -> Result<Option<&[RdNode]>, RdShapeError>
pub fn inspect_encoding(&self) -> Result<Option<&[RdNode]>, RdShapeError>
Strict counterpart to the lossy Self::encoding accessor.
Sourcepub fn inspect_doc_type(&self) -> Result<Option<&[RdNode]>, RdShapeError>
pub fn inspect_doc_type(&self) -> Result<Option<&[RdNode]>, RdShapeError>
Strict counterpart to the lossy Self::doc_type accessor.
Sourcepub fn inspect_rd_version(&self) -> Result<Option<&[RdNode]>, RdShapeError>
pub fn inspect_rd_version(&self) -> Result<Option<&[RdNode]>, RdShapeError>
Strict counterpart to the lossy Self::rd_version accessor.
Sourcepub fn inspect_synopsis(&self) -> Result<Option<&[RdNode]>, RdShapeError>
pub fn inspect_synopsis(&self) -> Result<Option<&[RdNode]>, RdShapeError>
Strict counterpart to the lossy Self::synopsis accessor.
Sourcepub fn inspect_aliases(
&self,
) -> impl Iterator<Item = Result<RdAlias<'_>, RdShapeError>> + '_
pub fn inspect_aliases( &self, ) -> impl Iterator<Item = Result<RdAlias<'_>, RdShapeError>> + '_
Strict counterpart to the lossy Self::aliases accessor.
Sourcepub fn inspect_keywords(
&self,
) -> impl Iterator<Item = Result<RdKeyword<'_>, RdShapeError>> + '_
pub fn inspect_keywords( &self, ) -> impl Iterator<Item = Result<RdKeyword<'_>, RdShapeError>> + '_
Strict counterpart to the lossy Self::keywords accessor.
Sourcepub fn inspect_concepts(
&self,
) -> impl Iterator<Item = Result<RdConcept<'_>, RdShapeError>> + '_
pub fn inspect_concepts( &self, ) -> impl Iterator<Item = Result<RdConcept<'_>, RdShapeError>> + '_
Strict counterpart to the lossy Self::concepts accessor.
Sourcepub fn section_tree(&self) -> impl Iterator<Item = RdSectionVisit<'_>>
pub fn section_tree(&self) -> impl Iterator<Item = RdSectionVisit<'_>>
Lossy depth-first preorder traversal of recognized top-level
\section nodes and recognized nested \subsection nodes.
Malformed candidates and their descendants are skipped. An orphan
top-level \subsection is outside this view; source-parser diagnostics
own that condition. See Self::sections for the top-level-only view.
Sourcepub fn inspect_section_tree(
&self,
) -> impl Iterator<Item = Result<RdSectionVisit<'_>, RdShapeError>>
pub fn inspect_section_tree( &self, ) -> impl Iterator<Item = Result<RdSectionVisit<'_>, RdShapeError>>
Strict depth-first preorder traversal of recognized top-level
\section nodes and recognized nested \subsection nodes.
Each malformed candidate yields one error and its descendants are not
traversed. An orphan top-level \subsection is outside this view;
source-parser diagnostics own that condition. See Self::sections
for the top-level-only view.
Sourcepub fn inspect_sections(
&self,
) -> impl Iterator<Item = Result<RdSection<'_>, RdShapeError>> + '_
pub fn inspect_sections( &self, ) -> impl Iterator<Item = Result<RdSection<'_>, RdShapeError>> + '_
Strict counterpart to the lossy Self::sections accessor.
Sourcepub fn inspect_arguments(
&self,
) -> Result<impl Iterator<Item = Result<RdArgument<'_>, RdShapeError>> + '_, RdShapeError>
pub fn inspect_arguments( &self, ) -> Result<impl Iterator<Item = Result<RdArgument<'_>, RdShapeError>> + '_, RdShapeError>
Strict counterpart to the lossy Self::arguments accessor.
Source§impl RdDocument
impl RdDocument
Sourcepub fn inspect_dynamic_markup(&self) -> RdDynamicMarkupIter<'_> ⓘ
pub fn inspect_dynamic_markup(&self) -> RdDynamicMarkupIter<'_> ⓘ
Returns a depth-first pre-order resolver for \\RdOpts and \\Sexpr.
The resolver deliberately mirrors R’s observable processRdSexprs
semantics: a single options state is folded in document order.
Conditional markup (\\if/\\ifelse) is not branch-selected here;
therefore an \\RdOpts in an arm that a renderer would not select
still affects later \\Sexpr resolution, matching R’s behavior.
Source§impl RdDocument
impl RdDocument
Sourcepub fn generation_header(&self) -> Option<RdGenerationHeader<'_>>
pub fn generation_header(&self) -> Option<RdGenerationHeader<'_>>
Returns the recognized generation header in the leading top-level region.
The view scans only leading comments interleaved with whitespace text. It is lossy: near-miss text is not recognized, and there is deliberately no inspection variant because this view has no structural error state.
Source§impl RdDocument
impl RdDocument
pub fn lifecycle_badges(&self) -> RdLifecycleBadges<'_>
pub fn inspect_lifecycle_badges(&self) -> RdLifecycleBadges<'_>
Source§impl RdDocument
impl RdDocument
pub fn system_macro_items(&self) -> RdSystemMacroItems<'_> ⓘ
pub fn inspect_system_macro_items(&self) -> RdSystemMacroItemsStrict<'_> ⓘ
Trait Implementations§
Source§impl Clone for RdDocument
impl Clone for RdDocument
Source§fn clone(&self) -> RdDocument
fn clone(&self) -> RdDocument
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more