This article walks through the basics of the framework.
The diagram to the right shows the overall data flow.
section
articleBodyWire value: "articleBody"
Appears on: Tutorial Article
A grep of src/components/ for the literal string "articleBody" finds exactly
one file:
Article.vue#L45-L50,
which declares a SectionKind lookup object listing the four section kinds a tutorial
article page can contain: articleBody, callToAction, hero,
assessments. Article.vue is the top-level page component for the
article topic kind, wired up from
Topic.vue#L31-L40
(as distinct from DocumentationTopic.vue, which renders API/symbol reference pages and
never sees an articleBody section at all — that kind belongs exclusively to the
tutorial-flavored render tree).
The dispatch itself happens in Article.vue's componentFor(section) method:
componentFor(section) {
const { kind } = section;
return {
[SectionKind.articleBody]: Body,
[SectionKind.callToAction]: CallToAction,
[SectionKind.hero]: Hero,
[SectionKind.assessments]: Assessments,
}[kind];
},
(Article.vue#L113-L121.)
The matching prop-extraction table only forwards the section's content field through to
the Body component:
propsFor(section) {
const { abstract, action, anchor, assessments, backgroundImage, chapter, content,
estimatedTimeInMinutes, kind, media, projectFiles, title, video, xcodeRequirement } = section;
return {
[SectionKind.articleBody]: { content },
...
}[kind];
},
(Article.vue#L125-L145.)
So an articleBody section is rendered by
Article/Body.vue#L11-L15,
a thin wrapper (<div class="body"><BodyContent :content="content" /></div>)
that forwards straight through to
Article/BodyContent.vue#L11-L21.
BodyContent.vue does the real layout dispatch: it iterates the content array
(each entry is a layout item, not a block-content node) and, keyed on that item's own
kind, resolves it to one of three layout components:
const LayoutKind = { columns: 'columns', contentAndMedia: 'contentAndMedia', fullWidth: 'fullWidth' };
componentFor(section) {
return {
[LayoutKind.columns]: Columns,
[LayoutKind.contentAndMedia]: ContentAndMedia,
[LayoutKind.fullWidth]: FullWidth,
}[section.kind];
},
(BodyContent.vue#L28-L52,
components at Article/Layouts/Columns.vue, Article/Layouts/ContentAndMedia.vue,
Article/Layouts/FullWidth.vue.) Each of those layout components ultimately hands its own
prose content down into ContentNode.vue, the shared block/inline-content renderer, for the
actual Markdown-derived HTML.
On the swift-docc production side, this section is emitted by
RenderNodeTranslator.visitTutorialArticle(_:), which builds a
TutorialArticleSection(content: layouts) and appends it to node.sections
right after the intro/hero section:
let layouts = contentLayouts(article.content)
let articleSection = TutorialArticleSection(content: layouts)
node.sections.append(articleSection)
(swift-docc, Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift, around
lines 970–974, inside visitTutorialArticle(_:).) The Swift-side type that carries this
payload is TutorialArticleSection
(Sources/SwiftDocC/Model/Rendering/Tutorial Article/TutorialArticleSection.swift) — this is
the swiftStructSite that was not pinned in the task brief; it was located by searching
Sources/SwiftDocC/Model/Rendering/ for the enclosing type of the .articleBody
case declared at the given swiftCaseSite
(RenderSection.swift#L15-L17).
DocCArchive's generated type is named ArticleBodyRenderSection (an OpenAPI Generator name
derived from the vendored JSON Schema's object key, not a name that appears anywhere in swift-docc's own
Swift source — swift-docc calls the same wire shape TutorialArticleSection).
No fixture containing the literal string "articleBody" as a JSON kind value
was found. DocCArchive's own test fixtures (ExampleDocs.doccarchive,
SampleLibrary.doccarchive) contain only symbol/API documentation-topic pages, never a
tutorial-format article page, so they contain no RenderSection payloads of any
kind (a grep for articleBody in those archives' data/ trees turns up nothing;
the only hits anywhere under Tests/DocCArchiveTests/Fixtures/ are inside the archives'
bundled, minified topic.c7f55345.js runtime script, not RenderNode data). swift-docc's own
test suite (Tests/SwiftDocCTests/Model/SemaToRenderNodeTests.swift) exercises this section
by asserting against the decoded Swift value (renderNode.sections[1] as? TutorialArticleSection,
asserting content.count == 8) rather than against a literal JSON fixture string, so there is
no ready-made JSON blob to lift verbatim from that test either. The example below is therefore
hand-written to match the vendored schema exactly.
{
"kind": "articleBody",
"content": [
{
"kind": "fullWidth",
"content": [
{
"type": "heading",
"level": 2,
"text": "Getting started",
"anchor": "getting-started"
},
{
"type": "paragraph",
"inlineContent": [
{ "type": "text", "text": "This article walks through the basics of the framework." }
]
}
]
},
{
"kind": "contentAndMedia",
"media": "diagram.png",
"mediaPosition": "trailing",
"content": [
{
"type": "paragraph",
"inlineContent": [
{ "type": "text", "text": "The diagram to the right shows the overall data flow." }
]
}
]
}
]
}
This article walks through the basics of the framework.
The diagram to the right shows the overall data flow.
mockup: the outer article.body-content element wraps one fullWidth
layout item (rendered as ordinary flowing prose) followed by one contentAndMedia layout
item (rendered as a two-column row, media on the trailing side per mediaPosition).
Source: Sources/DocCArchive/Vendored/RenderNode.spec.json, schema object
#/components/schemas/ArticleBodyRenderSection, cross-checked against
Components.Schemas.ArticleBodyRenderSection in
Sources/DocCArchive/generated/Types.swift (lines 3145–3170).
| Field | Type | Required | Enum values / default | Note |
|---|---|---|---|---|
kind |
string | yes | "articleBody" (single-value enum) |
Generated as KindPayload: String, Codable, Hashable, Sendable, CaseIterable { case articleBody }.
On the swift-docc production side this is a hardcoded constant
(public let kind: RenderSectionKind = .articleBody), never a value read from input. |
content |
array of RenderBlockContent (per the vendored JSON Schema) |
yes | — | The vendored schema types every item as a plain RenderBlockContent block, but this is
a schema/model mismatch worth flagging: swift-docc's actual TutorialArticleSection.content
is [ContentLayout] — a distinct three-case enum (fullWidth,
contentAndMedia, columns) whose members are themselves keyed by a
kind/content pair, only one of whose cases (fullWidth) directly
holds an array of RenderBlockContent. The other two cases (contentAndMedia,
columns) wrap ContentAndMediaSection value(s), which have their own
media/mediaPosition/content fields not represented anywhere in
the vendored RenderBlockContent schema. A DocCArchive consumer decoding real tutorial-article
JSON with the generated [Components.Schemas.RenderBlockContent] type would therefore fail
to decode (or silently misinterpret) any contentAndMedia/columns layout item —
see Section 4. |
Rendered DOM, outer to inner:
div.body — the root element of Article/Body.vue
(Body.vue#L11-L15).
Styled in the same file's <style scoped> block
(Body.vue#L27-L62):
background comes from the CSS custom property --colors-text-background falling back to
--color-article-body-background, and the block is given a border-radius: 10px
plus a negative transform: translateY(...) so it visually overlaps the section above it
(the intro/hero), collapsing back to no transform/no radius at the small breakpoint.article.body-content — the root element of Article/BodyContent.vue
(BodyContent.vue#L11-L21),
padded via the calculate-column-width() SCSS function and $article-stacked-margin-large..layout — applied to each dynamically-resolved layout child
(Columns/ContentAndMedia/FullWidth) via class="layout"
on the <component :is="componentFor(section)"> tag itself
(BodyContent.vue#L13-L19);
the sibling-combinator rule .layout + * { margin-top: $article-stacked-margin-large; }
supplies consistent vertical spacing between successive layout items.
SCSS files involved: src/components/Article/Body.vue (scoped style block),
src/components/Article/BodyContent.vue (scoped style block), and the shared
src/styles/_core.scss which both files @import for
$article-stacked-margin-large/$article-stacked-margin-small
(src/styles/core/_vars.scss, 40px/20px) and the breakpoint()/
breakpoint-content/calculate-column-width() mixins.
CSS custom properties consumed: --colors-text-background (theme override) falling back to
--color-article-body-background, defined per color scheme in
src/styles/core/colors/_light.scss (var(--color-fill)) and
src/styles/core/colors/_dark.scss (rgb(17, 17, 17)). Note this same property
is also consumed one level up, on div.article itself, at the small breakpoint
(Article.vue#L192-L202).
DocCArchive transform status: not yet implemented. MyHTMLTransformer and
MyMarkdownTransformer in Sources/DocCArchive/DocCArchive.swift 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 an ArticleBodyRenderSection's content array into HTML or
Markdown output, nor any code that would notice the schema/model content-type mismatch described in
Section 3.
NOT APPLICABLE
Current behavior in play: Article.vue's componentFor/propsFor
methods and BodyContent.vue's equivalent layout dispatch (Section 1) are pure,
one-time template-render lookups keyed on a static kind string already present in the
render JSON at page-load time — there is no component-local mutable state, no click handler, no
v-show/v-if toggle driven by user interaction, and no later change to which
branch of the lookup table is active. The translateY overlap and border-radius collapse in
Body.vue's styles are pure CSS media-query (breakpoint) responses, not state held in JS.
Because there is no interactive/stateful behavior here to replace — the entire "dispatch" is simply
"pick a Vue component to mount once, based on data already known when the page renders" — 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 page's behalf; a
static server-rendered HTML document with the same DOM shape would be behaviorally identical.