1. How swift-docc-render consumes this
Grepping src/components/ for the literal string 'codeVoice' lands on
src/components/ContentNode.vue's wire-constant table, where the InlineType object
maps the key to itself:
const InlineType = {
codeVoice: 'codeVoice',
...
};
(ContentNode.vue#L56-L69.)
That constant is matched inside the module-level renderNode() factory function
(defined at
ContentNode.vue#L121),
in its switch (node.type) dispatch table, immediately after the block-content
thematicBreak arm:
case InlineType.codeVoice:
return createElement(CodeVoice, {
class: 'inline-code',
}, (
node.code
));
(ContentNode.vue#L431-L436.)
The wire node's single payload field, code, is forwarded directly as the default slot
content—there is no intermediate transformation. The dispatch delegates to a dedicated child
component, CodeVoice, imported at
ContentNode.vue#L16
from
src/components/ContentNode/CodeVoice.vue,
whose entire template is:
<template>
<WordBreak tag="code"><slot /></WordBreak>
</template>
(CodeVoice.vue#L11-L13.)
CodeVoice has no props, no data(), and no logic of its own beyond
declaring its scoped <style> (covered in Section 4)—it delegates immediately to
WordBreak
(src/components/WordBreak.vue),
a functional component that renders the requested tag (here, code) and, if the
slotted content is a single raw text node, inserts <wbr> hints at safe character
boundaries (camelCase transitions, after colons, before dots/underscores) so long identifiers like
CustomStringConvertible.description can wrap on narrow viewports instead of overflowing.
The final DOM is therefore a bare <code class="inline-code">…</code>
element (with <wbr> nodes interleaved into its text) — there is no wrapping
<pre>, no syntax highlighting, and no click/hover behavior. This one-line-of-code
component is the simplest inline-content handler in the dispatch table alongside
thematicBreak's block-content counterpart.
Separately, ContentNode.vue also reads the codeVoice discriminator directly (not
through the dispatch table) inside its plaintext computed property, which walks the content
tree and concatenates a plain-text equivalent of the whole node—used, for example, for building
accessible/plaintext summaries elsewhere in the app:
if (node.type === InlineType.codeVoice) {
return `${text}${node.code}`;
}
(ContentNode.vue#L686-L688.)
This confirms code is treated as literal text with no nested inline content or markup of its
own—consistent with the schema in Section 3, where code is a plain string field, not an
array of child RenderInlineContent nodes.
2. Example JSON and rendered mockup
A real fixture was found: Tests/DocCArchiveTests/Fixtures/SampleLibrary.doccarchive/data/documentation/samplelibrary/samplestruct/description.json,
whose abstract array is a short run of inline content—plain text, a codeVoice
span naming the inherited property, and trailing punctuation:
{
"abstract": [
{
"text": "Inherited from ",
"type": "text"
},
{
"code": "CustomStringConvertible.description",
"type": "codeVoice"
},
{
"text": ".",
"type": "text"
}
]
}
Inherited from
CustomStringConvertible.description.
3. Data sheet
| field | type | required? | enum values / default | note |
|---|---|---|---|---|
type | string | yes | ["codeVoice"] | Discriminator; always the literal string "codeVoice". |
code | string | yes | — | The literal code text to render (e.g. a symbol name, variable, or operator). Plain text, not a nested array of RenderInlineContent—no formatting can be nested inside a codeVoice span. |
Source: Sources/DocCArchive/Vendored/RenderNode.spec.json, the CodeVoice schema
object (around line 1295, inside the RenderInlineContent discriminated-union definitions).
Cross-checked against the generated Swift type in
Sources/DocCArchive/generated/Types.swift:
public struct CodeVoice: Codable, Hashable, Sendable {
@frozen public enum _TypePayload: String, Codable, Hashable, Sendable, CaseIterable {
case codeVoice = "codeVoice"
}
public var _type: Components.Schemas.CodeVoice._TypePayload
public var code: Swift.String
...
}
This struct is one case (.CodeVoice) of the generated
Components.Schemas.RenderInlineContent discriminated union in the same file. On the
authoring side, swift-docc's Swift model defines the equivalent case as
case codeVoice(code: String) in
RenderInlineContent.swift (an enum, not a struct—so no separate
swiftStructSite exists upstream; the wire-level struct only exists in this repo's
OpenAPI-generated code), with its own Codable conformance encoding the same two keys,
type and code
(/Users/joeheck/src/swift-project/swift-docc/Sources/SwiftDocC/Model/Rendering/Content/RenderInlineContent.swift,
around line 34 for the case declaration).
4. HTML/CSS mapping in DocC-Render output
The rendered DOM is <code class="inline-code">…</code>, produced by
CodeVoice.vue wrapping its slot in a WordBreak that emits the requested
tag="code" element (with <wbr> word-break hints interleaved into the text
node, not wrapping elements). The scoped styles live directly in
src/components/ContentNode/CodeVoice.vue:
code {
speak-punctuation: code;
}
.inline-code {
background-color: var(--color-inline-code-background);
padding: var(--inline-code-padding);
border-radius: var(--inline-code-border-radius);
}
(CodeVoice.vue#L24-L34.)
Three CSS custom properties are consumed:
--color-inline-code-background— defined in the color-theme partialssrc/styles/core/colors/_light.scssand_dark.scss, both setting it totransparentin this checkout.--inline-code-paddingand--inline-code-border-radius— consumed only at this one call site; a repo-wide search ofsrc/for either name found no--inline-code-padding:or--inline-code-border-radius:definition anywhere in this checkout's SCSS/CSS/Vue sources. Either they are defined in a design-token layer not present in this snapshot, or they legitimately fall back to the CSS-wide initial value (effectively no padding/no rounding) unless overridden by a consuming app—this page states that gap honestly rather than guessing a value.
The speak-punctuation: code declaration is a CSS Speech Module property (assistive-technology
hint to read punctuation literally inside code spans); it is unscoped to .inline-code and
applies to any <code> element rendered by this component. No other DocC-Render SCSS
partial under src/styles/ targets .inline-code or CodeVoice
by name.
5. Modern CSS-only alternative
Not applicable
Current behavior, precisely: CodeVoice.vue holds no component state and no event handlers
at all—it is a pure, stateless mapping from { type: 'codeVoice', code: '...' } to a
<code class="inline-code"> element containing the literal code string (via
WordBreak's render function, which only decides where to insert <wbr> break
hints at render time). There is nothing to toggle, disclose, focus-trap, or navigate to: no
:checked-style state, no tab/panel switching, no hidden content revealed on interaction. The
entire "behavior" is a static text-formatting decision made once at render time based on the string's
character boundaries.
Because there is no interactive or stateful behavior in this kind to replace, none of the listed
mechanisms (<details>/<summary>, radio-input
:checked + sibling selectors, :target, the Popover API, <dialog>,
:has(), container queries, CSS anchor positioning, view-transitions) apply here. The one
genuinely CSS-relevant fact is that the visual treatment (background, padding, border-radius) is already
expressed purely through CSS custom properties consumed by a plain <code> element, which
is already the idiomatic, framework-free way to style inline code—there is no JS-held state for a
native mechanism to supersede.