1. How swift-docc-render consumes this
A quick warning about naming before anything else: the string "section" appears on the
RenderNode wire in two unrelated positions, and this page is about the reference-discriminator
one, not the page-kind one that several other things on the wire also happen to call
"section". Specifically:
RenderReferenceType.section(swift-docc:Sources/SwiftDocC/Model/Rendering/References/RenderReference.swift, line 29) — thetypediscriminator on an entry in a RenderNode's top-levelreferencesdictionary. This is the target of this page.RenderNode.Kind.section(swift-docc:Sources/SwiftDocC/Model/Rendering/RenderNode.swift, line 257) — a value of the separatekindfield carried inside aTopicRenderReference(and, unrelatedly, inside a top-level RenderNode's ownmetadata.role/kind-style fields elsewhere in the schema), meaning "this reference points at an in-page landmark/anchor," as opposed toarticle,symbol,project,overview, orroot.
Both values are produced together for the same reference object. In swift-docc's
DocumentationContentRenderer.renderReference(for:with:dependencies:), when a topic URL
resolves to a Markdown heading anchor rather than to a whole page (context.nodeAnchorSections[reference]
is non-nil), the content renderer builds a TopicRenderReference with
kind: .section, and later in the same function, sets renderReference.type = .section
whenever kind == .section
(swift-docc Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift, lines
299–308 and 450–452). So on the wire, a reference to an in-page landmark carries
"type": "section" and "kind": "section" simultaneously — the
struct underneath is the ordinary TopicRenderReference, not a distinct type.
On the decode side, swift-docc's own CodableRenderReference
(Sources/SwiftDocC/Model/Rendering/RenderNode/CodableRenderReference.swift, lines 25–46)
switches on the type discriminator and, for both .topic and .section,
decodes into the very same TopicRenderReference(from:) initializer:
switch type {
case .topic:
reference = try TopicRenderReference(from: decoder)
case .section:
reference = try TopicRenderReference(from: decoder)
...
}
Grepping swift-docc-render's src/components/ and src/views/ for the literal
string 'section' turns up no dedicated Vue component for this reference type — there is
no SectionReference.vue or similar. Instead, the render app treats "section" and
"topic" reference-type entries identically at every point that matters. The clearest evidence
is src/utils/references.js, lines 13–16:
const TopicReferenceTypes = new Set([
'section',
'topic',
]);
(utils/references.js#L13-L16.)
This set is used by filterInactiveReferences() in the same file to decide whether a reference
entry needs its url stripped when it originates from an archive that isn't in the currently
loaded/"included" set of archives; both section- and topic-typed references get
that same active/inactive URL-filtering treatment, unlike image, download, etc.
That function is called from DocumentationTopicStore.js's setReferences() action
(stores/DocumentationTopicStore.js#L39-L41),
which is how every RenderNode's references dictionary gets loaded into the app's shared
state before any component renders a link.
Once a reference entry is in that shared store, the actual dispatch site that turns a
type: "reference" inline-content node into a link is
ContentNode.vue's renderNode() function — but note this switches on the
inline-content node's own type ("reference"), not on the referenced object's
type ("topic"/"section"):
case InlineType.reference: {
const reference = references[node.identifier];
if (!reference) return null;
const titleInlineContent = node.overridingTitleInlineContent
|| reference.titleInlineContent;
const titlePlainText = node.overridingTitle || reference.title;
return createElement(Reference, {
props: {
url: reference.url,
kind: reference.kind,
role: reference.role,
isActive: node.isActive,
ideTitle: reference.ideTitle,
titleStyle: reference.titleStyle,
hasInlineFormatting: !!titleInlineContent,
},
class: 'inline-link',
}, (
titleInlineContent ? renderChildren(titleInlineContent) : titlePlainText
));
}
(ContentNode.vue#L467-L487.)
Notice the reference object's own type field ("topic" or "section")
is never read here at all — only its kind field is forwarded as a prop, straight into
ContentNode/Reference.vue. Inside Reference.vue, kind is checked
in exactly one place, isSymbolReference, which only special-cases
kind === 'symbol'
(ContentNode/Reference.vue#L77-L80). A reference whose kind is
"section" takes the same fallback path as article, project, and
overview kinds: it resolves to a plain internal/external link component
(ReferenceInternal.vue or ReferenceExternal.vue), which is just a
<router-link> (or plain <a> for external URLs) wrapping the slotted
title text — no distinct visual treatment exists for "this link points at a heading anchor" versus
"this link points at a whole page."
The one place a section-kind reference is treated distinctly (though still not with a
dedicated component) is the navigator sidebar's client-side filtering: TopicTypes.section
(src/constants/TopicTypes.js, line 42) is mapped to the "tutorials" filter-tag bucket in
TOPIC_TYPE_TO_TAG
(constants/Tags.js#L29-L39), consumed by the navigator's
tagsProvider and filteredChildren mixins when the sidebar's type-filter chips are
applied — so a section/anchor reference, if it ever appears as a navigator child node, is bucketed
alongside tutorials for filtering purposes, not alongside articles or symbols.
See also: The references map — how this and every other reference-dictionary lookup works across kinds.
2. Example JSON and rendered mockup
No fixture in this repository's test archives (ExampleDocs.doccarchive,
SampleLibrary.doccarchive) or in swift-docc's own
Tests/SwiftDocCTests/ JSON/Swift-literal fixtures contains a reference with
"type": "section" as of the pinned commits — both example docs projects link only to
whole pages, never to a Markdown heading anchor by URL fragment, so swift-docc never had reason to emit an
anchor-section reference for them. The example below is therefore hand-written to match the wire schema
(Section 3) and the encode path in DocumentationContentRenderer.swift lines 299–308.
{
"type": "section",
"kind": "section",
"identifier": "doc://com.example.ExampleDocs/documentation/ExampleDocs/ExampleArticle#Overview",
"title": "Overview",
"url": "/documentation/exampledocs/examplearticle#Overview",
"abstract": []
}
Inline content referencing this entry (e.g. "For more, see <doc:ExampleArticle#Overview>"):
mockup: the rendered result is an ordinary <a>/<router-link>
produced by ReferenceInternal.vue, styled with the shared .inline-link rule
(see Section 4). Nothing in the DOM or CSS distinguishes a link to an anchor/section from a link to a
whole page — the only difference is that url carries a #Overview
fragment, and the destination page must contain an element whose id matches that
fragment (produced by a heading block's own anchor field, see the
heading reference page on this site).
3. Data sheet
Source: Sources/DocCArchive/Vendored/RenderNode.spec.json, schema object
#/components/schemas/TopicRenderReference (lines 1742–1840), cross-checked against
Components.Schemas.TopicRenderReference in
Sources/DocCArchive/generated/Types.swift (lines 2473–2622). There is no separate
SectionRenderReference schema object — "section" is one of two allowed
values of this single struct's type field (the other being "topic"), and,
independently, one of six allowed values of the same struct's kind field.
| Field | Type | Required | Enum values / default | Note |
|---|---|---|---|---|
type |
string | yes | "topic" | "section" |
Generated as _TypePayload: String, Codable, Hashable, Sendable, CaseIterable { case topic =
"topic"; case section = "section" }, decoded/encoded under the Swift property name
_type via CodingKeys.case _type = "type". This is the reference-dictionary
discriminator documented on this page. |
kind |
string | yes | "article" | "project" | "section" | "overview" | "symbol" | "root" |
Generated as KindPayload, a separate six-case enum. "section" here means
"this reference points at an in-page landmark," and swift-docc always sets it in lockstep with
type: "section" (see Section 1) — but the wire schema itself does not encode that
coupling; nothing prevents a hand-written or third-party RenderNode from setting kind: "section"
with type: "topic" or vice versa. |
title |
string | yes | — | For a section/anchor reference, this is the anchor's heading title
(AnchorSection.title, swift-docc Sources/SwiftDocC/Model/AnchorSection.swift,
line 20), not the containing page's title. |
identifier |
string | yes | — | Key into the RenderNode's top-level references dictionary; for a section reference this
is the resolved topic URL including the URL fragment (e.g. doc://.../Article#Heading). |
url |
string | yes | — | Presentation URL, also fragment-bearing for a section reference (e.g.
/documentation/.../article#Heading). |
abstract |
array of RenderInlineContent |
no | default [] |
swift-docc's renderReference(for:with:dependencies:) returns immediately with an empty
abstract for the anchor-section early-exit path (lines 299–308); a full section reference built via
the general path further down borrows the abstract of the containing symbol, not the heading
itself (lines 334–343: "Sections don't have their own abstract so take the one of the container
symbol"). |
required |
boolean | no | default false (field omitted on the wire when false) |
Generated as Swift.Bool?. |
role |
string (DocumentationRole ref) |
no | — | Not set on the anchor-section early-exit path; would be nil/absent for a pure
heading-anchor reference. |
fragments, navigatorTitle |
array of DeclarationToken |
no | — | Symbol-only fields (abbreviated declaration for links/navigator); not populated for section/anchor references, which are never symbols. |
conformance |
object (ConformanceSection ref) |
no | — | Symbol-only; not applicable to section references. |
estimatedTime |
string | no | — | nil on the anchor-section early-exit path. |
beta, deprecated |
boolean | no | default false (field omitted when false) |
Generated as Swift.Bool?; swift-docc's encoder only writes these keys when true. |
titleStyle |
string | no | "title" | "symbol" |
Property-list-key display-style hint; not applicable to section references. |
name, ideTitle |
string | no | — | Property-list/entitlement-key naming fields; not applicable to section references. |
images |
array of TopicImage |
no | default [] |
Author-provided page images; empty for a section/anchor reference since anchors are not pages. |
tags |
array of SymbolTag |
no | — | Not populated on the anchor-section early-exit path. |
On the swift-docc production side (secondary/flavor source, not authoritative for wire shape), the
discriminator enum is declared at Sources/SwiftDocC/Model/Rendering/References/RenderReference.swift,
line 29:
public enum RenderReferenceType: String, Codable, Equatable {
case image, video, file, fileType, xcodeRequirement, topic, section, download, link, externalLocation
case unresolvable
}
and the struct that carries it, TopicRenderReference
(Sources/SwiftDocC/Model/Rendering/References/TopicRenderReference.swift, lines 12–16),
defaults its own type property to .topic:
public struct TopicRenderReference: RenderReference, VariantContainer, Equatable {
public var type: RenderReferenceType = .topic
...
}
It is only mutated to .section imperatively, after construction, by
DocumentationContentRenderer.renderReference(for:with:dependencies:)
(Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift, lines 450–452:
if kind == .section { renderReference.type = .section }), and by the dedicated early-return
branch for anchor sections that constructs the reference with kind: .section directly
(same file, lines 299–308). Authoring-side, an anchor/section reference is produced whenever a
Markdown link target resolves to a heading inside another page rather than to the page itself — for
example a doc-link written as <doc:SomeArticle#Some-Heading>, or a Markdown link
[text](SomeArticle.md#Some-Heading), where Some-Heading matches a heading's
derived anchor slug in the target article/tutorial. swift-docc's context tracks these under
DocumentationContext.nodeAnchorSections: [ResolvedTopicReference: AnchorSection]
(Sources/SwiftDocC/Infrastructure/DocumentationContext.swift, line 142), populated by
DocumentationCurator as it walks headings while resolving curated links.
DocCArchive's own transform layer does not yet do anything with this kind: MyHTMLTransformer
and MyMarkdownTransformer (Sources/DocCArchive/DocCArchive.swift, lines
242–254) are still stub placeholders that return a hardcoded HTML comment and an empty string
respectively for an entire RenderNode, with no reference-dictionary handling reached yet
— so a decoded Components.Schemas.TopicRenderReference with
_type: .section is available on the model today (via the generated
Components.Schemas.References discriminated-union case at line 2127,
case TopicRenderReference(Components.Schemas.TopicRenderReference)), but nothing in this
repository currently reads it or converts it into HTML or Markdown output.
4. HTML/CSS mapping in DocC-Render output
Because no dedicated component exists for this reference type (Section 1), the rendered DOM for a
section-typed/section-kinded reference is exactly the DOM produced for an
ordinary internal topic link:
a.inline-link(a Vue Router<router-link>, rendered as<a>, fromReferenceInternal.vue) — wraps the slotted title text; the.inline-linkclass is applied byContentNode.vue'screateElement(Reference, { ... class: 'inline-link' })call at the inline-reference dispatch site (ContentNode.vue#L473-L486), not by any component that knows the reference is a section/anchor link specifically.- The link's
href/totarget is the reference'surlvalue, fragment and all (e.g./documentation/exampledocs/examplearticle#Overview); the fragment navigation itself is handled by the browser/Vue Router, not by any DocC-render-authored CSS or JS specific to this reference kind.
SCSS: the only styling rule that applies is the shared, kind-agnostic inline-link rule in
src/styles/base/_typography.scss, line 141:
a {
color: var(--colors-link, var(--color-link));
&:link, &:visited { text-decoration: none; }
// Inline links need to be underline under WCAG 2.2 compliance
&:hover, &.inline-link { @include underline-text; }
&:active { text-decoration: none; }
}
(styles/base/_typography.scss#L131-L148.)
CSS custom properties consumed: --colors-link (falling back to --color-link) for
link text color. No SCSS file anywhere in src/styles/ or any component's scoped
<style> block keys off kind === 'section' or type === 'section'
— the visual result of following a section/anchor link is indistinguishable from following any other
topic link; only the destination page's own :target-independent scroll-to-heading behavior
(driven by LinkableHeading.vue's anchor-linked heading, documented on the
heading reference page) makes the fragment do anything once the browser arrives.
5. Modern CSS-only alternative
Not applicable
Current behavior in play: a section-typed reference entry carries no interactive or
stateful UI behavior of its own. It is a static data record (title, url, kind, abstract) rendered, via
ContentNode.vue's InlineType.reference case and Reference.vue's
refComponent computed property, into a single <a>/<router-link>
element whose only "state" is Vue Router's client-side navigation on click — there is no toggle, no
tab, no show/hide, no JS-held boolean that a CSS mechanism like :checked,
<details>, or the Popover API could take over, because there is nothing here for such a
mechanism to hold in place of JavaScript. The one piece of dynamic behavior anywhere near this kind
— scrolling to and focusing the destination heading after navigation — belongs to the
destination page's heading/LinkableHeading.vue rendering (already
covered, and already partly native via :target-style fragment navigation, on the
heading reference page), not to this reference-type kind itself. Concluding "not applicable"
here reflects that this kind is a stateless data-carrying wire object with a plain-link rendering; there is
no client-side interactive behavior on this kind for a native CSS mechanism to replace.