#[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-tagparse_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 noRd_tagat all and are represented asRdNode::Group. It is modeled here asRdTag::List."TEXT","RCODE","VERB", and"COMMENT"are leaf pseudo-tags. They are deliberately notRdTagvariants: they identify a leaf’s content kind, not a markup macro, and map directly to theRdNodeleaf variantsText,RCode,Verb, andCommentrespectively. Note this is a distinct concept fromRdTag::Verb, which is the\verb{...}macro (aTaggednode whose child is typically aVERB-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
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{...}: 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
\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
impl RdTag
Sourcepub fn from_rd_tag(tag: &str) -> RdTag
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.
Sourcepub fn as_rd_tag(&self) -> &str
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.