1. How swift-docc-render consumes this
A grep of src/components/ for the literal string 'text' lands, like every other
block/inline content kind on this reference site, on src/components/ContentNode.vue. Near the
top of the file its inline-kind wire constants are declared in one object,
ContentNode.vue#L56-L69,
whose text key holds the literal string 'text' (InlineType.text =
'text'). A comment directly above the renderNode() factory function calls this kind
out specifically:
// Recursively call the passed `createElement` function for each content node
// and any of its children by mapping each node `type` to a given Vue component
//
// Note: A plain string of text is returned for nodes with `type="text"`
(ContentNode.vue#L117-L121.)
The dispatch arm itself, in renderNode()'s switch (node.type), is exactly that
— it returns a JavaScript string rather than a Vue createElement() vnode:
case InlineType.text:
return node.text === '\n' ? (
createElement('br')
) : (
node.text
);
(ContentNode.vue#L493-L498.)
text is the only inline kind on this site with no wrapping element at all in the common case:
Vue accepts a plain string as a vnode child and inserts it as a raw DOM text node, so the rendered output
contributes no tag, class, or id of its own — it is literally the characters of node.text
spliced into whatever parent element (<p>, <strong>,
<li>, a table cell, etc.) is building its children via renderChildren().
The one special case is a literal newline character: node.text === '\n' is rendered as a hard
line break element, <br>, instead of an actual \n character (which HTML
would otherwise collapse into a single space).
Because a text node carries no inlineContent/content children field
(only the string in text), it does not appear as a recursion case in the file's other two
traversal helpers, map()
(ContentNode.vue#L550-L604)
and forEach()
(ContentNode.vue#L611-L652)
— both fall through to their generic default: return fn(node) arm for a bare text
node, since there is nothing nested to walk into. It does, however, appear explicitly in the component's
plaintext computed property, which reduces an entire content tree to a single string (used
for things like search snippets):
if (node.type === InlineType.text) {
return `${text}${node.text}`;
}
(ContentNode.vue#L680-L698,
case at line 689–691.) There, a text node's .text string is simply
concatenated onto the accumulator — it is the base case that terminates recursion for every other inline
kind's plain-text extraction (codeVoice uses .code instead;
reference looks up a title from references; everything else falls through to
the unchanged accumulator).
ContentNode.vue itself has no template and no <style> block — it is a
render-function-only component. It is always mounted from a wrapping component (for a symbol/article
page, src/components/DocumentationTopic/ContentNode.vue) whose own root element and scoped
stylesheet supply whatever visual context a run of plain text sits inside.
See also: The references map — how this and every other reference-dictionary lookup works across kinds.
2. Example JSON and rendered mockup
Real fixture: Tests/DocCArchiveTests/Fixtures/ExampleDocs.doccarchive/data/documentation/exampledocs/examplearticle.json,
field primaryContentSections[0].content[1].inlineContent[0] — the sole inline child of the
article's first authored paragraph. This is the RenderNode swift-docc produced for a run of unformatted
Markdown prose.
{
"type": "paragraph",
"inlineContent": [
{
"type": "text",
"text": "Description of what the article is about - the problem being solved, etc."
}
]
}
Description of what the article is about - the problem being solved, etc.
mockup: the text node contributes no element of its own — it is the raw character
data inside the enclosing <p> (or whatever inline-formatting element wraps it, e.g.
<strong> for a strong node's inlineContent). A second fixture
example, Tests/DocCArchiveTests/Fixtures/SampleLibrary.doccarchive/.../samplemethod().json's
abstract[0] field, shows the same shape used outside a paragraph, as the entire abstract of
a symbol: {"type": "text", "text": "A sample method that does something."}.
3. Data sheet
Source: Sources/DocCArchive/Vendored/RenderNode.spec.json, schema object
#/components/schemas/Text (lines 1227–1242), cross-checked against
Components.Schemas.Text in Sources/DocCArchive/generated/Types.swift (lines
1660–1685). Text is one arm of the RenderInlineContent discriminated
union (#/components/schemas/RenderInlineContent, lines 1190–1226; generated as
Components.Schemas.RenderInlineContent, an indirect enum at lines
1535–1658, with case Text(Components.Schemas.Text) at line 1537).
| Field | Type | Required | Enum values / default | Note |
|---|---|---|---|---|
type |
string | yes | "text" (single-value enum) |
Generated as _TypePayload: String, Codable, Hashable, Sendable, CaseIterable { case text =
"text" }, decoded/encoded under the Swift property name _type via an explicit
CodingKeys mapping (case _type = "type"), the same discriminator-renaming
pattern used for every other kind on this site. |
text |
string | yes | — | The literal run of plain text. Generated as public var text: Swift.String. This is the
only payload field — Text is the simplest object in the whole schema: two required string
properties and nothing else (no children array, no formatting, no identifier). |
On the swift-docc production side (secondary/flavor source, not authoritative for wire shape), the
enclosing Swift type is declared at
Sources/SwiftDocC/Model/Rendering/Content/RenderInlineContent.swift: the enum case
case text(String) (line 45, with doc comment "A piece of plain text"). Unlike most of its
sibling cases, .text has no nested payload struct of its own — it wraps a bare
String associated value, not a Text-named struct — so there is no
swiftStructSite to cite for this kind beyond the enum case declaration itself. The enclosing
RenderInlineContent enum's doc comment (lines 11–31) frames inline elements generally as
things a renderer "append[s] to previous inline elements" and gives an ASCII diagram showing
[Text] [Strong [Text]] [Text] [Emphasize [Reference]] as the contents of one paragraph —
plain Text nodes are the leaves that carry the actual prose, with every other inline kind
existing to add formatting or linking around one or more of them. Authoring-side, a text
node is what swift-docc emits for any span of authored Markdown that isn't itself wrapped in inline
formatting syntax (no **bold**, _italics_, backtick code voice, or
[link]()) — there is no directive an author writes to "create" one; it is the default leaf
kind for prose characters, matching the DocCArchive MyMarkdownTransformer.swift-relevant
observation in Section 5 below that regenerating those characters back to Markdown is exactly the
identity operation for this kind.
4. HTML/CSS mapping in DocC-Render output
Rendered DOM for a text node, in context:
- No element, class, or id of any kind.
renderNode()returns the JavaScript stringnode.textdirectly (seeContentNode.vue#L493-L498), and Vue'screateElement-based render pipeline inserts a plain string child as a raw DOMTextnode (no wrapping<span>). There is nothing to select in CSS that targets atextnode specifically — it is inseparable from its parent element's text content. - The one exception is a literal
"\n"payload, which becomes a bare<br>element instead of a string child — also with no class or id. - Its parent is whichever element the enclosing inline/block kind created (a bare
<p>for a paragraph'sinlineContent,<strong>/<em>for formatting wrappers, an<li>for a list item, a table<td>, etc.) — see theblock-paragraphreference page on this site for the most common host.
SCSS: because a text node contributes no element, there is no SCSS file that targets it and
no scoped style block anywhere in ContentNode.vue or its wrapper
(src/components/DocumentationTopic/ContentNode.vue) that could target it — a search of
src/styles/ for a text-specific selector turns up nothing, because the visual
appearance of the characters is entirely inherited from whichever parent element (paragraph, heading,
list item, table cell, emphasis wrapper) actually exists in the DOM. All font, color, and spacing
comes from that parent's rules — e.g. src/styles/base/_typography.scss's
font-styles(body) mixin, inherited via body, is what a bare run of text
ultimately renders with when its host is an unstyled <p>.
CSS custom properties consumed: none directly. A text node has no rendered element to attach
a custom property to; any typographic custom properties in play (font size, line height, color) are
consumed by the parent element the text is inserted into, not by the text run itself.
5. Modern CSS-only alternative
Not applicable
Current behavior in play: rendering a text node involves no JavaScript state and, more
unusually among the kinds on this site, no DOM element at all — renderNode()'s
InlineType.text arm is a pure, one-shot expression that returns either the string
node.text or a static <br> vnode for a literal newline. There is no click
handler, no v-show/v-if toggle, no component data() tracking any
kind of open/active state, and nothing that persists or changes after the initial paint. It is the most
minimal possible unit of content in the schema: a string, spliced verbatim into its parent.
Concretely: none of the interactive-state mechanisms this survey looks for
(<details>/<summary>, radio-input :checked plus a
general sibling selector, :target, the Popover API, <dialog>,
:has(), container queries, CSS anchor positioning, view transitions) apply here, because none
of them are standing in for any behavior this kind has — there is no behavior, interactive or otherwise,
beyond "insert these characters." The verdict is "not applicable" for the same reason it would be for any
raw string literal: there is no state to hold and no element to hold it on.