1. How swift-docc-render consumes this
A grep of src/constants/ and src/components/DocumentationTopic/ for the literal
string content: finds the dispatch table for a symbol reference page's "primary content"
sections in
constants/PrimaryContentSection.js#L12-L27,
which declares a plain SectionKind lookup object whose content key holds the
literal wire string 'content'. That constant is consumed by
DocumentationTopic/PrimaryContent.vue#L73-L90,
the component that renders a symbol page's primaryContentSections array:
componentFor(section) {
return {
[SectionKind.attributes]: Attributes,
[SectionKind.content]: ContentNode,
[SectionKind.details]: PropertyListKeyDetails,
[SectionKind.parameters]: Parameters,
[SectionKind.properties]: PropertyTable,
[SectionKind.restBody]: RestBody,
[SectionKind.restParameters]: RestParameters,
[SectionKind.restHeaders]: RestParameters,
[SectionKind.restCookies]: RestParameters,
[SectionKind.restEndpoint]: RestEndpoint,
[SectionKind.restResponses]: RestResponses,
[SectionKind.possibleValues]: PossibleValues,
[SectionKind.mentions]: Mentions,
}[section.kind];
},
A section whose kind is "content" is therefore mounted as the
ContentNode component, and its props are extracted immediately below in the matching
propsFor(section) table
(PrimaryContent.vue#L91-L127),
which forwards only the section's own content field through: [SectionKind.content]:
{ content }. Every other section kind in the same table (attributes,
parameters, properties, the REST kinds, etc.) gets its own dedicated
presentation component; content is the one kind that is handed straight to the generic
block-content renderer with no section-specific chrome at all.
DocumentationTopic/ContentNode.vue
(ContentNode.vue#L11-L26)
is itself just a thin wrapper that re-exports the props/methods of the shared, non-page-specific
src/components/ContentNode.vue — the same component every other block/inline content
dispatch on this reference site (headings, paragraphs, asides, tab navigators, etc.) ultimately goes
through. That shared component's render function is
(ContentNode.vue#L525-L545):
render: function render(createElement) {
// Dynamically map each content item and any children to their
// corresponding components, and wrap the whole tree in a <div>
return createElement(this.tag, { class: 'content' }, (
this.content.map(renderNode(createElement, this.references), this)
));
},
So the content array of a ContentRenderSection is walked item-by-item through
ContentNode.vue's internal renderNode() dispatcher (the same
node.type-keyed switch statement that every block/inline content kind on this site is
documented against) and the whole tree is wrapped in one root element — by default a
<div class="content">, though the wrapping tag is overridable via the component's
tag prop (unused at this call site, so the default div applies).
Zooming out one more level: PrimaryContent is itself only mounted from
DocumentationTopic.vue#L129-L135,
gated on a computed property that filters out declarations-kind sections
(DocumentationTopic.vue#L593-L600, primaryContentSectionsSanitized) —
content sections pass through this filter untouched and are rendered in whatever order
swift-docc emitted them in primaryContentSections.
On the swift-docc production side, this exact wire shape is produced by two different section
translators that both hardcode kind: .content:
DiscussionSectionTranslator.translateSection(for:renderNode:renderNodeTranslator:)
(Sources/SwiftDocC/Model/Rendering/RenderSectionTranslator/DiscussionSectionTranslator.swift,
line 45 — ContentRenderSection(kind: .content, content: discussionContent.capitalizingFirstWord(),
heading: title), where title is computed to be "Overview" or
"Discussion" depending on the symbol's role/kind) and
ReturnsSectionTranslator.translateSection(for:renderNode:renderNodeTranslator:)
(Sources/SwiftDocC/Model/Rendering/RenderSectionTranslator/ReturnsSectionTranslator.swift,
line 31 — same call shape, but with heading: "Return Value"). A third call site,
RenderNodeTranslator.swift line 679/1168, produces the same section for a symbol's
discussion and for a manually-authored Task Group's inline discussion. In every case the
ContentRenderSection.init(kind:content:heading:)
(Sources/SwiftDocC/Model/Rendering/Symbol/ContentRenderSection.swift, lines 23–29) is
what turns the optional heading parameter into an actual RenderBlockContent.heading
block prepended to content — the heading is not a separate JSON field; it is baked into the
same content array the client renders, which is why ContentNode.vue alone
(with no dedicated heading prop) is sufficient to render it.
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]. This is the "Overview" discussion section swift-docc
generates for an authored ## Overview Markdown heading followed by prose and a code
listing — the same shape DiscussionSectionTranslator produces for any symbol's discussion
text (see Section 1).
{
"kind": "content",
"content": [
{
"type": "heading",
"anchor": "Overview",
"level": 2,
"text": "Overview"
},
{
"type": "paragraph",
"inlineContent": [
{ "type": "text", "text": "Description of what the article is about - the problem being solved, etc." }
]
},
{
"type": "codeListing",
"syntax": "swift",
"code": [
"func main() {",
" print(\"hello world\")",
"}"
]
},
{
"type": "heading",
"anchor": "Section-header",
"level": 3,
"text": "Section header"
},
{
"type": "paragraph",
"inlineContent": [
{ "type": "text", "text": "Details, step by step, or explanations grouped by section headers." }
]
}
]
}
Description of what the article is about - the problem being solved, etc.
func main() {
print("hello world")
}
Details, step by step, or explanations grouped by section headers.
mockup: the whole array is emitted as one flat, flowing div.content — the
heading blocks are ordinary content items in the array, not section titles rendered by
a wrapper component; there is no visual separator between this section and neighboring
primaryContentSections entries beyond the vertical margin added by
PrimaryContent's own stylesheet (Section 4).
3. Data sheet
Source: Sources/DocCArchive/Vendored/RenderNode.spec.json, schema object
#/components/schemas/ContentRenderSection (lines 2716–2734), cross-checked against
Components.Schemas.ContentRenderSection in
Sources/DocCArchive/generated/Types.swift (lines 6275–6300). This is one of thirteen
arms of the DocumentationPrimaryRenderSection discriminated union (schema line 2507) that
makes up a symbol RenderNode's primaryContentSections array.
| Field | Type | Required | Enum values / default | Note |
|---|---|---|---|---|
kind |
string | yes | "content" (single-value enum) |
Generated as KindPayload: String, Codable, Hashable, Sendable, CaseIterable { case content }.
On the swift-docc production side the same wire value is written for two distinct
RenderSectionKind Swift cases, .discussion and .content — both
decode through ContentRenderSection(from:) in
CodableContentSection.swift (lines 41–45) — but every encoding call site in
swift-docc's translators always passes kind: .content explicitly, so "discussion"
is never actually observed on the wire for this section type. |
content |
array of RenderBlockContent |
yes | — | Arbitrary block content — matches swift-docc's Swift-side ContentRenderSection.content:
[RenderBlockContent] exactly (no schema/model mismatch here, unlike some other section kinds).
Swift-side, an optional heading constructor parameter
(ContentRenderSection.init(kind:content:heading:)) is not a separate wire field at all —
when supplied it is spliced into this same array as a leading RenderBlockContent.heading
block before encoding, so a consumer cannot distinguish "author-provided heading" from
"synthesized section title" once the JSON has been produced. |
4. HTML/CSS mapping in DocC-Render output
Rendered DOM, outer to inner, for a content-kind entry inside a symbol page's primary
content list:
div.primary-content— the root element ofDocumentationTopic/PrimaryContent.vue(PrimaryContent.vue#L11-L20), which iterates every section (not justcontent-kind ones) and mounts a dynamic<component :is="componentFor(section)">for each.div.content— the root element produced by the sharedsrc/components/ContentNode.vuerender function for this particular section (ContentNode.vue#L525-L545); its children are whatever block-content components (<h2>/<h3>headings,<p>paragraphs,<pre><code>code listings, asides, tables, tab navigators, etc.) eachcontentarray item resolves to via that component's internalrenderNode()switch. Note the class name collision: this innerdiv.contentis an implementation detail of the generic content renderer and is unrelated to (and nested inside) the outer JSON field also namedcontent.
SCSS files involved: src/components/DocumentationTopic/PrimaryContent.vue's scoped style
block
(PrimaryContent.vue#L132-L155),
which imports the shared src/styles/_core.scss for the
$section-spacing-single-side (40px) and $contenttable-spacing-single-side
(2.353rem) SCSS variables used to space each rendered section vertically from its neighbors; and
src/components/ContentNode.vue's own scoped style block, which styles the block-level
children (code listings, images, lists, asides) that actually appear inside the inner
div.content.
CSS custom properties consumed: --colors-grid (falling back to --color-grid)
and --content-table-title-border-width (falling back to 1px), both used by
.primary-content.with-border::before to draw the horizontal rule above the whole primary
content block on non-"enhanced-background" symbol pages
(PrimaryContent.vue#L135-L143).
Inside ContentNode.vue, code listings additionally consume
--background/--color-code-background and
--text/--color-code-plain for their syntax-highlighted background/foreground.
DocCArchive transform status: not yet implemented. MyHTMLTransformer and
MyMarkdownTransformer in Sources/DocCArchive/DocCArchive.swift (lines
242–254) are still stub placeholders — the HTML transformer returns a hardcoded
<!-- what? --> comment regardless of input, and the Markdown transformer returns an
empty string — so there is no code path today that walks a ContentRenderSection's
content array (or the [RenderBlockContent] items inside it) into HTML or
Markdown output.
5. Modern CSS-only alternative
NOT APPLICABLE
Current behavior in play: the dispatch chain described in Section 1
(PrimaryContent.vue's componentFor/propsFor lookup tables,
followed by ContentNode.vue's render() function) is a pure, one-time
template-render decision keyed on a static kind string that is already present in the
RenderNode JSON at page-load time. There is no component-local mutable state guarding whether a
content section is shown, no click handler, no v-show/v-if toggle
driven by user interaction, and nothing that changes which DOM subtree is mounted after the initial
render. The vertical spacing between sections ($section-spacing-single-side,
$contenttable-spacing-single-side) and the optional top border
(.primary-content.with-border::before) are static CSS rules evaluated once from
already-known props/class bindings, not state machines. Because there is no interactive/stateful
behavior here to replace — the entire mechanism is "pick a Vue component to mount once, based on data
already known when the page renders, then lay out its children with ordinary flow and margin rules" —
none of <details>/<summary>, radio+:checked,
:target, the Popover API, <dialog>, :has(), container
queries, CSS anchor positioning, or view-transitions has any state to hold on this section's behalf; a
static server-rendered div.content with the same children would be behaviorally identical.
(Individual block-content items nested inside — e.g. a tab navigator or disclosure aside — may have
their own genuinely interactive behavior, but that is scoped to those child kinds' own reference pages,
not to the content section wrapper documented here.)