1. How swift-docc-render consumes this
section is a case of RenderNode.Kind
(Sources/SwiftDocC/Model/Rendering/RenderNode.swift, line 257 at the pinned commit),
but a full top-level RenderNode is never actually emitted with
kind: "section". Grepping every call site that constructs a page-level
RenderNode(identifier:kind:) in swift-docc
(RenderNodeTranslator.swift) turns up only four values in practice —
.tutorial, .overview, .article, .symbol —
and the vendored JSON schema agrees: TutorialsPageRenderNode.kind only allows
"overview" | "project" | "article", and there is a separate
DocumentationRenderNode schema for symbol/article pages. section is used
exclusively as the kind (and, when so, also the type discriminator) of a
TopicRenderReference — i.e. it labels a
reference to an on-page anchor inside a Tutorial, not a page of its own.
The producing code is
DocumentationContentRenderer.renderKindAndRole(_:semantic:)
(Sources/SwiftDocC/Model/Rendering/DocumentationContentRenderer.swift, lines 249–266):
when the referenced documentation node's kind is DocumentationNode.Kind.onPageLandmark
— the internal kind assigned to each authored @Section inside a Tutorial page
— the reference's rendered kind is set to .section:
case .onPageLandmark:
return (.section, role)
Further down in the same file, renderReference(for:with:dependencies:)
(lines 291–456) also special-cases this: a section reference borrows its abstract from the
*containing* page rather than having its own (lines 335–344, "Sections don't have their own
abstract so take the one of the container symbol"), and separately forces the reference's
type discriminator to .section too, not just its kind
(lines 450–452):
if kind == .section {
renderReference.type = .section
}
On the authoring/translation side, each @Section in a .tutorial file
becomes an .onPageLandmark child node
(Sources/SwiftDocC/Semantics/Tutorial/Tasks/TutorialSection.swift, directive name
"Section"), and RenderNodeTranslator.visitTutorial(_:)
(RenderNodeTranslator.swift, lines 202–212) looks up those landmark children to
attach an anchor fragment string to each rendered TutorialSectionsRenderSection.Section:
let sectionReferences = context.children(of: identifier, kind: .onPageLandmark)
tutorialSections.tasks = tutorialSections.tasks.enumerated().map { (index, section) in
var section = section
section.anchor = sectionReferences[index].reference.fragment ?? ""
return section
}
On the swift-docc-render side, a real search of src/components/ for the literal
string "section" as a reference kind comparison turns up no dedicated Vue
component — there is no SectionReference.vue or equivalent. Instead, a
kind: "section" TopicRenderReference flows through the same generic
inline-reference pipeline as every other topic reference. The dispatch site is
ContentNode.vue's render function, case InlineType.reference
(src/components/ContentNode.vue, lines 467–487), which resolves the reference
from the page's references map and passes its kind/role
straight through as props to a generic
ContentNode/Reference.vue component:
case InlineType.reference: {
const reference = references[node.identifier];
if (!reference) return null;
...
return createElement(Reference, {
props: {
url: reference.url,
kind: reference.kind,
role: reference.role,
...
},
...
}, ...);
}
Reference.vue's own doc comment even cites the exact wire-schema location for this
kind prop (its @param kind block links to
RenderNode.spec.json's DocumentationRenderNode.kind). Internally it only
special-cases kind === 'symbol' (to decide whether to render a monospace "display
symbol" variant); every other kind, including section, falls through
isSymbolReference as false. Since a tutorial-section anchor URL is a
same-page or same-origin path (e.g. /tutorials/.../MyTutorial#My-Section, never an
external scheme), isInternal is true, so refComponent
resolves to plain
ReferenceInternal.vue
— a bare Vue Router <router-link> wrapping the slotted title text, with no
icon, badge, or kind-specific styling at all.
The only two places in swift-docc-render that inspect the literal string "section" as
a topic-type value are non-visual bookkeeping tables:
src/constants/TopicTypes.js (line 42, just declares the string constant
TopicTypes.section = 'section') and
src/constants/Tags.js, line 35, which maps it into the "tutorials" content-type
filter bucket used by API-reference search/filter UI ([TopicTypes.section]:
FILTER_TAGS.tutorials). Separately,
TopicTypeIcon.vue (used by the navigator sidebar and quick-navigation modal, not by
inline content references) has no entry for TopicTypes.section in its
TopicTypeIcons lookup map, so any icon request for a section-kind item silently falls
back to the default CollectionIcon (line 124: TopicTypeIcons[normalisedType]
|| CollectionIcon).
The actual scroll target that a section reference's URL fragment points at is rendered by
a different component entirely:
components/Tutorial/Section.vue wraps each tutorial section's intro/steps content in a
LinkableSection (aliased from
LinkableElement.vue), which renders <div :id="anchor"> — the
literal DOM id that the reference's #fragment URL resolves against. It
also registers itself with an injected store and an IntersectionObserver
mixin so the section-tracking dropdown (Tutorial/NavigationBar/SecondaryDropdown.vue)
can highlight whichever section is currently scrolled into view; that dropdown's own use of the
literal string 'section' (line 86, an aria-current="section" value) is an
unrelated ARIA landmark token, not this wire kind.
See also: The references map — how this and every other reference-dictionary lookup works across kinds.
2. Example JSON and rendered mockup
Neither DocCArchive's fixtures (ExampleDocs.doccarchive,
SampleLibrary.doccarchive under Tests/DocCArchiveTests/Fixtures/, both
generated from a plain library/article project with no .tutorial content and
therefore no data/tutorials/ directory at all) nor swift-docc's test suite (grepped
for "kind": "section" / "kind":"section" and for
RenderNode.Kind.section / kind: .section Swift literals across
Tests/SwiftDocCTests/) contain a fixture exercising this exact reference kind. The
example below is hand-written to match the field-level constraints in the data sheet below, shaped
around a two-section tutorial and the single cross-reference (from the tutorial's own "Next Steps"
paragraph, pointing back at its own first section) that would carry kind: "section".
{
"type": "topicRenderReference",
"identifier": "doc://org.swift.docc.example/tutorials/TechnologyX/MyTutorial#Create-a-New-Project",
"title": "Create a New Project",
"abstract": [
{ "type": "text", "text": "Set up the Xcode project used throughout this tutorial." }
],
"url": "/tutorials/technologyx/mytutorial#Create-a-New-Project",
"kind": "section",
"type": "section",
"role": "pseudoSymbol",
"required": false,
"isBeta": false,
"isDeprecated": false,
"images": []
}
(Note: the wire encoding shown here uses type to mean the
RenderReferenceType discriminator ("topic" vs. "section"),
per TopicRenderReference's Codable implementation; a real archive's
references map key would be the identifier string, and this whole object
would appear as one dictionary value alongside sibling topic-kind references for the
tutorial's other, page-level links.)
Rendered inline, inside a paragraph of body text:
Once you've explored the API, return to Create a New Project to try the alternate configuration.
mockup: a plain in-line link, indistinguishable in style from a link to a full
article or symbol page — Reference.vue applies no
section-specific icon, badge, or color, unlike its handling of kind: "symbol"
references (which can render as a monospace "display symbol"). The only visual difference from a
plain external link is that clicking it triggers Vue Router's in-page anchor scroll instead of a
full navigation.
3. Data sheet
Source: Sources/DocCArchive/Vendored/RenderNode.spec.json, schema object
#/components/schemas/TopicRenderReference (lines 1742–1840), cross-checked
against the generated Components.Schemas.TopicRenderReference struct in
Sources/DocCArchive/generated/Types.swift (lines 2473–2530+). section
is one enum case shared across two different fields on this one schema object — it is not a
separate discriminated schema of its own.
| Field | Type | Required | Enum values / default | Note |
|---|---|---|---|---|
kind |
string | yes | "article" | "project" | "section" | "overview" | "symbol" | "root" |
Generated as TopicRenderReference.KindPayload (6 cases). Note this vendored
enum's "root" case has no corresponding case in the hand-written Swift
RenderNode.Kind enum at RenderNode.swift line 257 (which only has
symbol, article, tutorial("project"), section, overview) — a drift between the
vendored JSON Schema and the current Swift source at the pinned commits, orthogonal to the
section case documented here but worth flagging since both live on the same enum.
section is set only via DocumentationContentRenderer.renderKindAndRole's
.onPageLandmark case. |
type |
string | yes | "topic" | "section" |
Generated as TopicRenderReference._TypePayload (2 cases) — this is the
RenderReferenceType discriminator used by CodableRenderReference to pick
which Swift struct to decode a reference into. Both "topic" and "section"
decode to the same TopicRenderReference struct
(CodableRenderReference.swift, line 38: case .section: reference = try
TopicRenderReference(from: decoder)) — it exists purely so JSON consumers can
distinguish "reference to a full page" from "reference to an on-page anchor" without having to
inspect kind too. swift-docc sets both this field and kind to
"section" together (never one without the other). |
title |
string | yes | — | The heading text of the @Section. |
identifier |
string | yes | — | Key into the enclosing RenderNode's references map; also the resolved topic
reference URL including its #fragment. |
url |
string | yes | — | Site-relative presentation URL, e.g. /tutorials/technologyx/mytutorial#Section-Anchor;
consumed directly by ReferenceInternal.vue's router-link :to. |
abstract |
array of RenderInlineContent |
no | default [] |
For a section-kind reference, swift-docc deliberately borrows the
containing page's abstract rather than generating one from the section body
(DocumentationContentRenderer.swift, lines 335–344), since an
@Section has no abstract of its own in the authoring model. |
role |
DocumentationRole (string enum, vendored separately) |
no | — | DocumentationContentRenderer.role(for:) maps
DocumentationNode.Kind.onPageLandmark to role .pseudoSymbol
(DocumentationContentRenderer.swift, line 162), reflecting that an on-page landmark is
treated internally similarly to a symbol member for indexing/hierarchy purposes even though it
isn't a real symbol. |
required |
boolean | no | default false |
Not applicable to sections in practice; inherited generically from the shared
TopicRenderReference struct. |
fragments, navigatorTitle |
array of DeclarationToken |
no | — | Symbol-only fields (abbreviated declaration for links/navigator); always nil
for a section-kind reference since a tutorial section is never a symbol. |
conformance, defaultImplementations, beta,
deprecated, titleStyle, ideTitle, name |
various | no | — | All symbol/property-list-key-only fields on the shared struct; not meaningfully populated for
section references. |
estimatedTime |
string | no | — | Populated from the *referenced page's* estimated duration when present — for an on-page-landmark reference this is generically inherited from the shared code path, not specific to sections. |
tags |
array of SymbolTag |
no | — | SPI/beta-style tags; generically available but not section-specific. |
4. HTML/CSS mapping in DocC-Render output
There is no dedicated DOM subtree for "a kind: section reference" as such — it
renders through the fully generic inline-reference chain described in section 1:
Reference.vue's root is a dynamic<component :is="refComponent">; for an internal, non-symbol reference (which every section reference is) that resolves toReferenceInternal.vue, whose template is just<router-link v-if="url && isActive" :to="url"><slot /></router-link>— no wrapping element, no class, nodata-*attribute naming the reference'skindortypeat all. The rendered<a>only carries whatever class the calling context applies (ContentNode.vueaddsclass="inline-link"at the call site, line 483).- The link's destination DOM node — the element the URL's
#fragmentactually scrolls to — is<div id="{anchor}">, rendered byLinkableElement.vue(no CSS class of its own; the wrappingSection.vuecomponent addsclass="section"to that same element via its scoped style block). - SCSS:
Section.vue's own scoped<style lang="scss">block (importingdocc-render/styles/_core.scss) sets onlypadding-top: $tutorial-section-spacing-single-side;on.section— purely a spacing rule for the anchor target, unrelated to the reference/link styling.ReferenceInternal.vueandReference.vueship no scoped<style>block at all; link color/underline styling comes from whatever ancestor prose context (e.g.ContentNode.vue's.inline-linkrules) the reference happens to be embedded in. - No CSS custom properties are consumed specifically for the
sectionreference kind —TopicTypeIcon.vue's--icon-colorcustom property (used for itswithColorsmode) is never populated forsectionbecauseHeroColorsMaphas no entry for it either, and the icon component itself is not on the inline-reference render path in the first place.
DocCArchive transform status: MyHTMLTransformer and MyMarkdownTransformer
in Sources/DocCArchive/DocCArchive.swift are still stub placeholders (the HTML
transformer returns a hardcoded comment and the Markdown transformer returns an empty string) with
no kind-specific handling of any RenderReference, let alone this one; a future
implementation resolving inline reference nodes against the
references map would need to special-case kind == .section the same way
swift-docc-render's ContentNode.vue does, to know it is linking to an in-page anchor
rather than a distinct output document.
5. Modern CSS-only alternative
NOT APPLICABLE
Current behavior: nothing specific to the section reference kind holds any
client-side state. The only JS-driven interactivity anywhere near this kind belongs to two other
things that merely happen to share the same URL fragment as this reference's destination:
(1) LinkableElement.vue's IntersectionObserver-based
onIntersect mixin, which reports each section's scroll visibility up to an injected
store so the tutorial navigation dropdown can highlight the "currently reading"
section, and (2) Vue Router's client-side hash navigation, which intercepts the
router-link :to="url" click and smooth-scrolls to the matching id rather
than doing a full page load. Neither of those is a behavior of the section-kind
reference object itself (the thing this page documents) — they belong to the anchor
target and the router, respectively, and both already have close-enough native equivalents
(a bare <a href="#anchor"> plus the browser's native :target
scroll-into-view behavior would do the same job without any JS, modulo the "currently reading"
highlight, which would need a :target-based sibling selector instead of an
intersection observer). But this page's subject — the TopicRenderReference
JSON object and the plain <a>/router-link it renders as — is
itself stateless: it is a link, rendered once from static props, with no toggle, no expand/collapse,
and no modal to replace. There is no interactive behavior on this specific object to migrate to
<details>, :checked, :has(), or any other native
mechanism.