1. How swift-docc-render consumes this
"topic" is the type discriminator used on entries in a
RenderNode's top-level references dictionary that point at
another page of documentation (as opposed to an image, a download file, an external
link, etc.). Swift-docc's TopicRenderReference is the Swift model for this shape;
on the wire it is keyed by its identifier (a doc:// URL) inside
RenderNode.references, and other parts of the render node — most commonly a
"Topics" section's identifiers list —
reference it by that identifier instead of inlining the full object repeatedly.
The resolution and rendering chain in swift-docc-render is:
-
referencesProvider(a Vue mixin) exposes the render node's wholereferencesmap as a computed property, backed by the app's Vuex-likestore.state.references: src/mixins/referencesProvider.js#L11-L27. -
TopicsTable.vue(the component behind a page's rendered "Topics" section) takes eachsection.identifiersentry and looks it up in that map (this.references[id]), building asection.topicsarray of resolvedTopicRenderReferenceobjects: TopicsTable.vue#L108-L118. It then either hands each resolved topic toTopicsLinkBlock(list style, the default) or the whole array toTopicsLinkCardGrid(grid/card style), switching on atopicStyleprop: TopicsTable.vue#L35-L50. -
TopicsLinkBlock.vueis the component that actually renders one topic reference as a link row. Its root element is<div class="link-block">, containing a<router-link>(internal) or<a>(whentopic.type === 'link') wrapping aTopicLinkBlockIcon(role glyph), the title (asDecoratedTopicTitleif the reference carries symbolfragments, else plain text), and a following.abstractblock with the topic'sabstractcontent, badges for beta/deprecated status, and anytags: TopicsLinkBlock.vue#L11-L57. The component's own prop validator (not just documentation) enumerates the exact shape it expects a resolved topic reference to satisfy: TopicsLinkBlock.vue#L104-L119. -
Separately, the generic
Reference.vuecomponent (used for inline cross-references inside prose, not just the "Topics" section) accepts akindprop whose valid values are documented in its header comment as "SeeDocumentationRenderNode.kind"/TopicRenderReference.typein the JSON schema, and uses it (together withrole) to decide whether to render a symbol-styled link (ReferenceInternalSymbol/ReferenceExternalSymbol) or a plain link (ReferenceInternal/ReferenceExternal): Reference.vue#L40-L96.
The role-to-icon mapping used by TopicLinkBlockIcon (shown next to each topic link,
driven by the reference's role field, e.g. symbol, article,
collection) lives at
TopicLinkBlockIcon.vue#L17-L47.
See also: The references map — how this and every other reference-dictionary lookup works across kinds.
2. Example JSON and rendered mockup
Real fixture example, taken from this repository's own test fixture at
Tests/DocCArchiveTests/Fixtures/SampleLibrary.doccarchive/data/documentation/samplelibrary.json,
the entry for doc://SampleLibrary/documentation/SampleLibrary/SampleClass inside that
render node's references dictionary:
{
"abstract": [],
"fragments": [
{ "kind": "keyword", "text": "class" },
{ "kind": "text", "text": " " },
{ "kind": "identifier", "text": "SampleClass" }
],
"identifier": "doc://SampleLibrary/documentation/SampleLibrary/SampleClass",
"kind": "symbol",
"navigatorTitle": [
{ "kind": "identifier", "text": "SampleClass" }
],
"role": "symbol",
"title": "SampleClass",
"type": "topic",
"url": "/documentation/samplelibrary/sampleclass"
}
This particular reference has an empty abstract array and no tags,
images, beta, or deprecated flags in the fixture, so the
mockup below adds a short abstract and a beta badge (clearly labeled) purely to illustrate what
TopicsLinkBlock.vue shows when those optional fields are present.
SampleClass
BETA (illustrative, not in fixture)
3. Data sheet
Field table for the TopicRenderReference schema object, from
Sources/DocCArchive/Vendored/RenderNode.spec.json (schema
#/components/schemas/TopicRenderReference, lines 1742-1840) cross-checked against the
generated Components.Schemas.TopicRenderReference struct in
Sources/DocCArchive/generated/Types.swift (lines 2473-2600).
| Field | Type | Required? | Enum values / default | Note |
|---|---|---|---|---|
type | string | yes | "topic", "section" | Discriminator; generated as _TypePayload (renamed from type because type collides with Swift keyword handling). |
identifier | string | yes | — | The doc://-scheme key this object is stored under in RenderNode.references. |
title | string | yes | — | Display title of the destination page (variant-aware in the Swift model via titleVariants, but the wire field is a plain string). |
url | string | yes | — | Root-relative path to the destination page. |
kind | string | yes | article, project, section, overview, symbol, root | The kind of the referenced page, not of this reference object itself. Generated as KindPayload. Note this enum is narrower than the full RenderNode.Kind enum on the Swift-docc authoring side (which also has tutorial, tutorialTableOfContents, volume, video, etc.); swift-docc's decoder falls back to .tutorial if kind is missing entirely, for backwards compatibility with older archives. |
abstract | array of RenderInlineContent | no | default [] | Short inline-content summary of the destination page. |
required | boolean | no | default false | Whether the referenced symbol is a required protocol member. |
defaultImplementations | number | no | — | Count of default implementations for the referenced symbol; generated as Swift.Double? even though it is conceptually an integer count. |
fragments | array of DeclarationToken | no | — | Abbreviated declaration tokens shown inline in the link (e.g. class SampleClass). |
navigatorTitle | array of DeclarationToken | no | — | Abbreviated declaration tokens for the navigator sidebar. |
role | DocumentationRole (string enum) | no | e.g. symbol, article, collection, collectionGroup, ... | Drives the icon shown in TopicLinkBlockIcon.vue. |
images | array of TopicImage | no | — | Author-provided icon/card images for this page. |
conformance | ConformanceSection | no | — | Conditional-conformance info, symbols only. |
estimatedTime | string | no | — | Estimated time to complete (tutorials). |
beta | boolean | no | default false; JSON schema oddly lists "format": "true" | Whether the symbol is beta; only emitted when true (swift-docc's encoder omits it when false). |
deprecated | boolean | no | default false; same "format": "true" quirk | Whether the symbol is deprecated; only emitted when true. |
titleStyle | string | no | title, symbol | Only meaningful for property-list-key/entitlement-key references. |
name | string | no | — | Raw plist/entitlement key name (wire key name maps to Swift's propertyListKeyNames.rawKey). |
ideTitle | string | no | — | Wire key ideTitle maps to Swift's propertyListKeyNames.displayName. |
tags | array of SymbolTag | no | — | Free-text tags; TopicsLinkBlock.vue renders only the first one as a badge. |
Note: the JSON schema's type enum ("topic", "section") is
slightly broader than what its own name suggests — the same TopicRenderReference
struct is reused with type: "section" for references to task-group / volume
"section" pages inside tutorials, per swift-docc's own doc comment on
RenderReferenceType
(Sources/SwiftDocC/Model/Rendering/References/RenderReference.swift:29).
4. HTML/CSS mapping in DocC-Render output
div.link-block— root element rendered byTopicsLinkBlock.vuefor each resolved topic; modifier classes includehas-inline-element(no abstract/badges to show below the title) and a "changes" class when API-diff highlighting is active.a.link/router-link.link— the actual clickable link wrapping the icon + title; gets.deprecated(strikethrough) and.has-adjacent-elementswhen an abstract/badges follow.div.topic-icon-wrapper> role-specific SVG icon component (fromTopicLinkBlockIcon.vue).div.abstract— wraps the rendered abstractContentNode, plusdiv.topic-keyinfofor plist "Key/Name" lines andRequirementMetadata("Required." / default-implementation count) for protocol requirements.span.badge(componentBadge.vue) — used for the beta badge, deprecated badge, and the first entry oftags.- Enclosing structure from
TopicsTable.vue:ContentTable>ContentTableSection> (div.topicwrapper around eachTopicsLinkBlock, or aTopicsLinkCardGridwhen the page uses card/grid style instead of the list style).
SCSS: the scoped <style> block inside TopicsLinkBlock.vue defines
.link-block, .link, .abstract, .topic-required,
and .deprecated rules and imports the shared
docc-render/styles/_core.scss. It consumes two SCSS variables defined centrally in
src/styles/core/_vars.scss: $topic-link-icon-width
(1.294rem) and $topic-link-icon-spacing (1rem), used to
indent the abstract/badges so they line up with the title text after the icon. The scoped style
block inside TopicsTable.vue separately sets the vertical spacing (margin-top:
15px) between successive .topic entries.
5. Modern CSS-only alternative
Not applicable
A resolved topic reference, as rendered by TopicsLinkBlock.vue, is not
an interactive/stateful widget: there is no client-side toggle, tab, disclosure, or modal state
being held in Vue component data for a single topic link row. It is a link (an <a>
or Vue-Router <router-link>) with a decorated label, an optional abstract, and
optional status badges — all computed once from static props (topic.title,
topic.abstract, topic.beta, topic.deprecated, etc.) and
rendered declaratively; nothing in TopicsLinkBlock.vue's computed block
reacts to user interaction (clicking simply navigates, which is native browser/router behavior,
not a piece of UI state a CSS mechanism like :checked or :target would
need to replace). The one piece of "dynamism" — API-diff highlighting via changesClasses
— is itself just a class computed from external route/query state (which diff view is selected),
not something toggled by user interaction with this component. There is therefore no equivalent
click-driven show/hide, tab-switch, or expand/collapse behavior for a native HTML mechanism
(<details>, radio+:checked, :target, Popover API,
<dialog>) to take over; this kind is a static, link-based rendering.