1. How swift-docc-render consumes this
intro is a decode-only alias, not a value swift-docc-render's dispatch tables ever
see. Both "hero" and "intro" are declared as valid values of
RenderSectionKind at
RenderSection.swift#L15-L17,
and swift-docc's CodableRenderSection decoder accepts either one and routes both to the
same IntroRenderSection type:
switch kind {
case .hero, .intro:
section = try IntroRenderSection(from: decoder)
...
(CodableRenderSection.swift#L21-L46.)
But IntroRenderSection.kind itself is a hardcoded constant, not something set from the
decoded value:
public struct IntroRenderSection: RenderSection, Equatable {
public let kind: RenderSectionKind = .hero
...
(swiftCaseSite's enclosing struct,
IntroRenderSection.swift#L12-L13.)
So a RenderNode that swift-docc itself produces (via RenderNodeTranslator.visitIntro,
RenderNodeTranslator.swift#L294-L295)
always re-encodes as "kind": "hero", even if the section originated from JSON that said
"kind": "intro". swift-docc's own test suite documents this normalization explicitly, with a
comment stating the intent in plain words: "We should always output renderJSON that uses 'hero' to
describe an intro section to maintain compatibility" (see the Data sheet section below for the exact
test).
Because of that, a grep of
swift-docc-render@4a9efad637's
src/components/ and src/views/ for the literal string "intro" as a
kind discriminator turns up nothing — only unrelated CSS class names (a div.intro
wrapper inside Tutorial/Hero.vue, and a .intro class in
TutorialsOverview/Chapter.vue) and copy strings like "Watch intro video". The three actual
section-kind dispatch tables all key exclusively on hero:
Tutorial.vue'sSectionComponentsmap (Tutorial.vue#L46-L66):{ assessments: Assessments, hero: Hero, tasks: SectionList, callToAction: CallToAction }.Article.vue'sSectionKindmap pluscomponentFor(section)(Article.vue#L45-L124), which mapsherotoArticle/Hero.vue, a two-line wrapper that re-exportsTutorial/Hero.vueunchanged.TutorialsOverview.vue's inlineSectionKind-gated template (<Hero v-if="heroSection" ... />), which renders a separate, unrelated component,TutorialsOverview/Hero.vue.
None of these tables has an intro key, and no v-if/v-else branch
anywhere in the searched directories checks section.kind === 'intro'. In other words: even
though the wire schema and swift-docc's decoder both still recognize "intro" as an input
value (for backward compatibility with older-format render JSON), the current
swift-docc-render frontend was not found to contain any code path that would ever receive
"kind": "intro" in practice, because swift-docc normalizes it to "hero" before
any consumer sees it. This page therefore documents the wire alias and its rendering intent, but the
actual template/DOM/SCSS mechanics belong to the sibling page for hero
(kinds/section-hero.html), since they are, by construction,
the exact same IntroRenderSection payload and the exact same Tutorial/Hero.vue
component.
2. Example JSON and rendered mockup
Fixture source: Tests/SwiftDocCTests/Model/RenderSectionTests.swift,
testDecoderAcceptsIntroKeyAndOutputsHeroKey(), in the swift-docc repository. This test is
the most directly on-topic fixture available for the "intro" wire value: it feeds in JSON
using "kind": "intro" and asserts the re-encoded JSON uses "kind": "hero".
DocCArchive's own fixtures (ExampleDocs.doccarchive, SampleLibrary.doccarchive)
contain only documentation-topic pages (no tutorials or articles), so neither contains any
IntroRenderSection payload at all, let alone one using the "intro" spelling; and
a grep of Tests/SwiftDocCTests/ for "intro" as a kind value found
only this one test file.
Input JSON, as actually written on the wire:
{
"backgroundImage" : "intro_school.jpg",
"chapter" : "Getting Started",
"content" : [
{
"inlineContent" : [
{
"text" : "Here is some introduction text that will explain all the things and such you will be following this tutorial. You are going to learn a lot by building an app.",
"type" : "text"
}
],
"type" : "paragraph"
}
],
"estimatedTimeInMinutes" : 20,
"kind" : "intro",
"projectFiles" : "project.zip",
"title" : "Basic Augmented Reality App",
"video" : "video.mov",
"xcodeRequirement" : "Xcode 10 beta"
}
Output JSON, after being decoded and re-encoded by swift-docc:
{
"backgroundImage" : "intro_school.jpg",
"chapter" : "Getting Started",
"content" : [ /* ...unchanged... */ ],
"estimatedTimeInMinutes" : 20,
"kind" : "hero",
"projectFiles" : "project.zip",
"title" : "Basic Augmented Reality App",
"video" : "video.mov",
"xcodeRequirement" : "Xcode 10 beta"
}
Only kind changes. Every other field passes through untouched — confirming this is a pure
discriminator-value normalization, not a content transformation.
Getting Started
Here is some introduction text that will explain all the things and such you will be following this tutorial. You are going to learn a lot by building an app.
20 min · Project files · Xcode 10 beta required
mockup: the rendered result is visually identical to any other hero section
(see the hero page's mockup for a rendering that also
shows the call-to-action link) — because by the time it reaches the browser, it is a
hero section; the "intro" spelling never survives past swift-docc's own
decode/re-encode step.
3. Data sheet
Source: Sources/DocCArchive/Vendored/RenderNode.spec.json, schema object
#/components/schemas/IntroRenderSection (the kind property's
enum array is ["hero", "intro"]), cross-checked against the generated
Components.Schemas.IntroRenderSection.KindPayload enum in
Sources/DocCArchive/generated/Types.swift (lines 3115–3118).
| Field | Type | Required | Enum values / default | Note |
|---|---|---|---|---|
kind |
string | yes | "hero", "intro" |
Generated as KindPayload: String, Codable, ... CaseIterable { case hero, case intro }.
"intro" is a legacy/alternate spelling accepted by swift-docc's decoder
(CodableRenderSection) but never produced by swift-docc's own encoder — the
IntroRenderSection.kind Swift property is hardcoded to .hero (see Section 1).
Treat "intro" as a read-compatibility input value only. |
title |
string | yes | — | Rendered as the page's H1 via Headline in Tutorial/Hero.vue. |
content |
array of RenderBlockContent |
no | — | Generated as [RenderBlockContent]? (optional). Rendered via
ContentNode.vue inside div.intro (a CSS class, unrelated to the
kind discriminator discussed on this page). |
Same wire-schema/Swift-model gap noted on the hero page applies here,
since intro and hero decode to the identical Swift type: the vendored JSON
Schema (and therefore the generated Components.Schemas.IntroRenderSection Swift type)
only declares title, kind, and content, while swift-docc's actual
model at
IntroRenderSection.swift#L12-L46
(swiftStructSite, since none was pinned for this page — found by searching
Sources/SwiftDocC/Model/Rendering/) additionally encodes chapter,
estimatedTimeInMinutes, xcodeRequirement, backgroundImage,
action, image, video, and projectFiles — all five
of the "extra" fields shown in the Section 2 fixture (backgroundImage, chapter,
estimatedTimeInMinutes, video, xcodeRequirement,
projectFiles) that a DocCArchive consumer decoding with the generated type today would
silently drop. See the hero page's data sheet
for the full breakdown of those fields; nothing about that gap differs when the wire value happens to
be "intro" instead of "hero".
4. HTML/CSS mapping in DocC-Render output
There is no CSS or DOM structure specific to the "intro" spelling — because swift-docc
normalizes "intro" to "hero" before the render JSON is written to
data/ in a .doccarchive, swift-docc-render's dispatch tables (Section 1) never
branch on kind === "intro", so there is no distinct template, class, or SCSS rule to
document that differs from the hero case. The full DOM shape (root
LinkableSection anchor id="introduction", div.hero.dark,
div.bg, H1, div.intro, div.metadata) and the SCSS
custom properties it consumes (--color-tutorial-hero-background,
--color-tutorial-hero-text, --color-hero-eyebrow, from
src/styles/core/colors/_light.scss) are documented on
the hero page, Section 4 and apply identically
here, since they are produced by the same Tutorial/Hero.vue component regardless of which
spelling appeared in the source JSON before swift-docc's decode step.
DocCArchive transform status: MyHTMLTransformer and MyMarkdownTransformer in
Sources/DocCArchive/DocCArchive.swift are still stub placeholders (the HTML transformer
returns a hardcoded <!-- what? --> comment and the Markdown transformer returns an
empty string) — there is no kind-specific handling for intro/hero/
IntroRenderSection today, and because DocCArchive decodes with the generated type (which
only exposes title/kind/content), it also could not currently
tell an incoming "intro"-spelled section apart from any other metadata beyond that.
5. Modern CSS-only alternative
NOT APPLICABLE
Current behavior in play: "intro" is not a runtime UI state at all — it is a JSON string
discriminator that exists only inside swift-docc's Swift decoder
(CodableRenderSection.init(from:)'s switch kind { case .hero, .intro: ... }),
and it is fully resolved (normalized to "hero") before any HTML, Vue component, or CSS is
ever produced. There is no client-side branching, toggle, visibility state, or DOM structure that
depends on whether the original JSON said "hero" or "intro"; by the time
swift-docc-render's ContentNode/Tutorial.vue/Article.vue code
runs, only "hero" is possible. Since there is no rendering-time behavior distinguishing
these two spellings to replace, no native CSS mechanism (<details>, radio+:checked,
:target, Popover API, <dialog>, :has(), container queries,
anchor positioning, view-transitions) is relevant to this distinction. (The genuinely stateful
piece of the rendered output — the "Watch intro video" modal inside Tutorial/Hero.vue — is
identical regardless of the intro/hero spelling and is analyzed on
the hero page, Section 5, which reaches a
partial verdict for that unrelated interactive behavior via <dialog>.)