Skip to main content

RdTag

Enum RdTag 

Source
#[non_exhaustive]
pub enum RdTag {
Show 84 variants IfDef, IfNDef, Name, Alias, Title, Description, Usage, Arguments, Value, Details, Note, Author, References, SeeAlso, Examples, Keyword, Concept, Format, Source, Encoding, DocType, Rdversion, Synopsis, Section, Subsection, Item, Itemize, Enumerate, Describe, Tabular, Tab, Cr, Code, Special, Verb, Preformatted, Emph, Strong, Bold, Href, Url, Email, File, Pkg, Samp, SQuote, DQuote, Kbd, Var, Env, Command, Option, Acronym, Abbr, Cite, Dfn, Link, LinkS4Class, Figure, Doi, CranPkg, Sspace, I, Enc, Eqn, Deqn, Sexpr, RdOpts, If, IfElse, Out, DontRun, DontTest, DontShow, DontDiff, TestOnly, Method, S3Method, S4Method, R, Dots, LDots, List, Unknown(String),
}
Expand description

The closed vocabulary of Rd markup tags, as found in the Rd_tag string attribute R’s parse_Rd() attaches to each node of a parsed Rd object.

Every macro-shaped known tag stores the exact wire string (including the leading backslash, e.g. "\\title") so that RdTag::as_rd_tag round-trips through RdTag::from_rd_tag without loss.

Two tag-like strings are handled outside this closed macro vocabulary:

  • "LIST" is not a macro (no backslash): it is the pseudo-tag parse_Rd() attaches to a bare, un-named {...} brace group that appears directly in running text (as opposed to the positional argument groups of multi-argument macros such as \method{generic}{class}, which carry no Rd_tag at all and are represented as RdNode::Group. It is modeled here as RdTag::List.
  • "TEXT", "RCODE", "VERB", and "COMMENT" are leaf pseudo-tags. They are deliberately not RdTag variants: they identify a leaf’s content kind, not a markup macro, and map directly to the RdNode leaf variants Text, RCode, Verb, and Comment respectively. Note this is a distinct concept from RdTag::Verb, which is the \verb{...} macro (a Tagged node whose child is typically a VERB-tagged leaf).

Any other string – including tags for dynamically-expanded user macros such as USERMACRO (see the note on RdTag::Doi) – is preserved verbatim as RdTag::Unknown.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

IfDef

#ifdef target: conditionally included Rd content for a target.

§

IfNDef

#ifndef target: conditionally included Rd content when a target is absent.

§

Name

\name{...}: the topic’s name (required).

§

Alias

\alias{...}: an additional name this topic is looked up under.

§

Title

\title{...}: the topic’s one-line title (required).

§

Description

\description{...}: the topic’s short description (required).

§

Usage

\usage{...}: call signature(s), rendered as R code.

§

Arguments

\arguments{...}: the \item list describing each argument.

§

Value

\value{...}: description of the return value.

§

Details

\details{...}: extended description.

§

Note

\note{...}: supplementary remarks.

§

Author

\author{...}: author information.

§

References

\references{...}: bibliographic references.

§

SeeAlso

\seealso{...}: cross-references to related topics.

§

Examples

\examples{...}: runnable example R code.

§

Keyword

\keyword{...}: an R documentation keyword.

§

Concept

\concept{...}: a free-text concept index term.

§

Format

\format{...}: the structure of documented data.

§

Source

\source{...}: provenance of documented data.

§

Encoding

\encoding{...}: declares the source file’s encoding.

§

DocType

\docType{...}: the documentation object’s type (e.g. package).

§

Rdversion

\Rdversion{...}: the Rd format version the file was written for.

§

Synopsis

\synopsis{...}: an alternate usage synopsis (rare, legacy).

§

Section

\section{title}{...}: a custom top-level section.

The section title is carried by a child node (the section’s first argument group), not by this tag itself.

§

Subsection

\subsection{title}{...}: a custom section nested within another section’s content.

§

Item

\item{...} or \item{label}{...}: a list entry. Used both as a zero-argument separator inside \itemize/\enumerate (where the item’s content is the following sibling nodes up to the next \item) and as a two-argument label/description pair inside \describe and \arguments.

§

Itemize

\itemize{...}: a bulleted list of \items.

§

Enumerate

\enumerate{...}: a numbered list of \items.

§

Describe

\describe{...}: a description list of label/definition \items.

§

Tabular

\tabular{cols}{...}: a table, with \tab-separated cells and \cr-terminated rows.

§

Tab

\tab: a column separator inside \tabular.

§

Cr

\cr: a row terminator inside \tabular (also usable as a plain line break elsewhere).

§

Code

\code{...}: inline R code.

§

Special

\special{...}: R-like content for a special, non-standard usage form.

§

Verb

\verb{...}: verbatim inline text. Distinct from the VERB leaf pseudo-tag (see the enum-level documentation): a \verb{...} macro is a Tagged node whose child is typically a VERB-tagged leaf.

§

Preformatted

\preformatted{...}: a verbatim block.

§

Emph

\emph{...}: emphasized (italic) text.

§

Strong

\strong{...}: strongly emphasized (bold) text.

§

Bold

\bold{...}: bold text.

§

Href

\href{url}{text}: a hyperlink with explicit display text.

§

Url

\url{...}: a literal URL.

§

Email

\email{...}: an email address.

§

File

\file{...}: a file path.

§

Pkg

\pkg{...}: a package name.

§

Samp

\samp{...}: a literal sequence of characters (“sample”).

§

SQuote

\sQuote{...}: single-quoted text.

§

DQuote

\dQuote{...}: double-quoted text.

§

Kbd

\kbd{...}: keyboard input.

§

Var

\var{...}: a variable name.

§

Env

\env{...}: an environment variable name.

§

Command

\command{...}: a command name.

§

Option

\option{...}: a command-line option name.

§

Acronym

\acronym{...}: an acronym.

§

Abbr

\abbr{...}: an abbreviation.

§

Cite

\cite{...}: a citation reference.

§

Dfn

\dfn{...}: a defining instance of a term.

\link{topic} or \link[pkg]{topic} (or \link[pkg:target]{topic} via the option string): a cross-reference link. The optional package/target qualifier is carried in option.

§

LinkS4Class

\linkS4class{class} or \linkS4class[pkg]{class}: a cross-reference to S4 class documentation.

§

Figure

\figure{file} or \figure{file}{options}: an embedded image.

§

Doi

\doi{id}: a DOI link.

Note: in R’s own parse_Rd()/help-database pipeline, \doi (like \CRANpkg, \sspace, \I, and other convenience macros) is not a grammar token but a dynamic user macro loaded from share/Rd/macros/system.Rd. Its expansion shows up in the parsed tree as an Rd_tag = "USERMACRO" leaf followed by a nested \Sexpr call, not as a node tagged "\\doi". This variant is kept in the closed vocabulary because a hand-written Rd source parser (a producer that does not replicate R’s macro-expansion engine) may reasonably choose to recognize \doi directly; lowering from an installed help database will typically produce RdTag::Unknown("USERMACRO".into()) plus a Sexpr node instead.

§

CranPkg

\CRANpkg{package}: a reference to a package on CRAN.

R defines this in share/Rd/macros/system.Rd and expands it to an \href containing \pkg. rd-source preserves the source-level semantic operation directly instead of reproducing that expansion.

§

Sspace

\sspace: output-dependent sentence spacing.

R expands this system macro to a LaTeX/non-LaTeX \ifelse. Keeping it as a distinct tag preserves the output-sensitive source intent.

§

I

\I{...}: content marked to be ignored by RdTextFilter.

This system macro expands to its argument unchanged. It does not request italics, emphasis, or R’s AsIs class.

§

Enc

\enc{encoded}{ascii}: encoding-dependent text with an ASCII fallback.

§

Eqn

\eqn{latex} or \eqn{latex}{ascii}: an inline equation.

§

Deqn

\deqn{latex} or \deqn{latex}{ascii}: a displayed equation.

§

Sexpr

\Sexpr{code} or \Sexpr[options]{code}: dynamically generated content, evaluated at build or render time. Options (e.g. results=rd,stage=build) are carried in option.

§

RdOpts

\RdOpts{options}: sets default \Sexpr options for the remainder of the file.

§

If

\if{format}{content}: content included only for a specific output format.

§

IfElse

\ifelse{format}{then}{else}: format-conditional content with a fallback.

§

Out

\out{...}: raw, format-specific output passed through unescaped.

§

DontRun

\dontrun{...}: example code that should not be executed.

§

DontTest

\donttest{...}: example code that should not be tested automatically (but is shown and may be run manually).

§

DontShow

\dontshow{...}: example code that is executed but not displayed.

§

DontDiff

\dontdiff{...}: example code excluded from diff-based checking.

§

TestOnly

\testonly{...}: an alias for \dontshow.

§

Method

\method{generic}{class}: an S3 method usage entry.

§

S3Method

\S3method{generic}{class}: an S3 method usage entry (equivalent to \method).

§

S4Method

\S4method{generic}{signature}: an S4 method usage entry.

§

R

\R: the “R” logo/name.

§

Dots

\dots: the ... ellipsis.

§

LDots

\ldots: the ... ellipsis (alias for \dots; kept as a distinct variant because it is a distinct Rd_tag string and must round-trip exactly).

§

List

The bare brace-group pseudo-tag "LIST" (no leading backslash): a {...} group with no macro name, appearing directly in running text.

§

Unknown(String)

An Rd_tag string that isn’t part of the known vocabulary above, preserved exactly as encountered.

Implementations§

Source§

impl RdTag

Source

pub const KNOWN: &'static [RdTag]

All known (non-Unknown) tag variants, including List. Useful for exhaustive testing and introspection.

Source

pub fn from_rd_tag(tag: &str) -> RdTag

Parses the exact Rd_tag string as stored by a help database (i.e. with the leading backslash for macros, e.g. "\\title", "\\item", "\\Sexpr", and bare for the "LIST" pseudo-tag).

Unrecognized input is preserved exactly via RdTag::Unknown, so this function never fails.

Source

pub fn as_rd_tag(&self) -> &str

Returns the canonical wire-format string for this tag.

Guaranteed to round-trip through RdTag::from_rd_tag for every variant, including RdTag::Unknown.

Trait Implementations§

Source§

impl Clone for RdTag

Source§

fn clone(&self) -> RdTag

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RdTag

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for RdTag

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for RdTag

Source§

impl Hash for RdTag

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for RdTag

Source§

fn eq(&self, other: &RdTag) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for RdTag

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for RdTag

Auto Trait Implementations§

§

impl Freeze for RdTag

§

impl RefUnwindSafe for RdTag

§

impl Send for RdTag

§

impl Sync for RdTag

§

impl Unpin for RdTag

§

impl UnsafeUnpin for RdTag

§

impl UnwindSafe for RdTag

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.