1. How swift-docc-render consumes this
volume is the kind discriminator for VolumeRenderSection, one
of the top-level sections of a Tutorials Overview (a.k.a. "Table of Contents") page — the page
produced from a @Tutorials directive's .tutorial-adjacent overview file. The
outer page component,
TutorialsOverview.vue,
declares a small SectionKind map (hero, resources,
volume) used only to validate incoming sections and to split out the
hero section; every non-hero section (which in practice means every volume
and resources section) is handed to
LearningPath.vue
as otherSections.
LearningPath.vue is the actual dispatch site for this kind. It partitions
sections into volumes (everything with kind === 'volume') and
otherSections, renders every volume through a dedicated
<Volume v-for="(volume, i) in volumes"> loop, and renders the remaining sections
(currently only resources) through a generic componentFor(section) /
propsFor(section) lookup table:
const SectionKind = { resources: 'resources', volume: 'volume' };
...
partitionedSections: ({ sections }) => sections.reduce(([volumes, others], section) => (
section.kind === SectionKind.volume ? (
[volumes.concat(section), others]
) : (
[volumes, others.concat(section)]
)
), [[], []]),
volumes: ({ partitionedSections }) => partitionedSections[0],
otherSections: ({ partitionedSections }) => partitionedSections[1],
...
propsFor: ({ chapters, content, image, kind, name, tiles }) => ({
[SectionKind.resources]: { content, tiles },
[SectionKind.volume]: { chapters, content, image, name },
}[kind]),
Each matched section is rendered by
TutorialsOverview/Volume.vue,
whose entire template is:
<section class="volume">
<VolumeName v-if="name" v-bind="{ name, image, content }" />
<Chapter
v-for="(chapter, i) in chapters"
class="tile"
:content="chapter.content"
:image="chapter.image"
:key="chapter.name"
:name="chapter.name"
:number="i + 1"
:topics="lookupTopics(chapter.tutorials)"
:volumeHasName="!!name"
/>
</section>
When name is present, the volume's own header/blurb is delegated to
VolumeName.vue
(an Asset for image, an h2.name, and the content
array rendered through the shared ContentNode.vue). Each entry of chapters
is handed to Chapter.vue (not itself keyed by this kind, so out of scope for
this page) along with lookupTopics(chapter.tutorials), which resolves each tutorial's
reference-identifier string against the page's references map (via an injected
store) so Chapter.vue can render the actual tutorial tiles.
Volume.vue also mixes in
onIntersectViewport:
an IntersectionObserver watches the volume's root element, and whenever it crosses the
vertical center of the viewport while scrolling, the mixin calls
this.store.setActiveVolume(this.name). That store is
TutorialsOverviewStore,
a plain reactive object holding activeVolume (plus activeTutorialLink and
references). The sidebar,
TutorialsNavigation.vue,
reads state.activeVolume back out to decide which named-volume disclosure menu should be
expanded, and also writes to the store on click (onSelectMenu/onDeselectMenu),
so scrolling the main content and clicking the side nav both drive the same shared "which volume is
active" state.
See also: The references map — how this and every other reference-dictionary lookup works across kinds.
2. Example JSON and rendered mockup
No literal JSON fixture containing "kind": "volume" was found. DocCArchive's own
fixtures (ExampleDocs.doccarchive, SampleLibrary.doccarchive) contain only
documentation-topic pages, not tutorials, so the string "volume" only appears there
inside a minified render-side JS bundle
(js/tutorials-overview.9144a669.js), not as page data. swift-docc's test suite
(Tests/SwiftDocCTests/Model/SemaToRenderNodeTests.swift) exercises
VolumeRenderSection only via Swift-literal XCTAssert* calls against decoded
objects, not an embedded JSON literal, so there is no ready-made JSON string to lift either. The
example below is therefore hand-written to match the vendored schema exactly (required
kind + chapters; optional name, image,
content), using field values modeled on the names actually asserted in
SemaToRenderNodeTests.swift ("Volume 1", "Chapter 1",
figure1.png).
{
"kind": "volume",
"name": "Volume 1",
"image": "figure1.png",
"content": [
{
"type": "paragraph",
"inlineContent": [
{ "type": "text", "text": "Learn the basics of TechnologyX." }
]
}
],
"chapters": [
{
"name": "Chapter 1",
"content": [
{
"type": "paragraph",
"inlineContent": [
{ "type": "text", "text": "Get started with your first project." }
]
}
],
"tutorials": [
"doc://org.swift.docc.example/tutorials/Test-Bundle/TestTutorial"
],
"image": "figure1.png"
}
]
}
Learn the basics of TechnologyX.
Chapter 1
Get started with your first project.
mockup: a named volume band (VolumeName: image + h2 + intro
content) followed by one chapter tile per entry in chapters, each listing its
resolved tutorial tiles.
3. Data sheet
Source: Sources/DocCArchive/Vendored/RenderNode.spec.json, schema objects
#/components/schemas/VolumeRenderSection (lines 298–329) and
#/components/schemas/Chapter (lines 330–359), cross-checked against the generated
Components.Schemas.VolumeRenderSection / Components.Schemas.Chapter structs
in Sources/DocCArchive/generated/Types.swift (lines 3386–3464). This pairing matches
swift-docc's own VolumeRenderSection.swift field-for-field, including the same optional
name, image, content and required chapters.
| Field | Type | Required | Enum values / default | Note |
|---|---|---|---|---|
kind |
string | yes | "volume" |
Generated as a one-case KindPayload enum. In swift-docc's Swift model this defaults
to .volume in the property declaration (public var kind: RenderSectionKind =
.volume), and VolumeRenderSection hand-writes its own encode(to:) to
guarantee name is emitted as JSON null (not omitted) for anonymous
volumes. |
name |
string | no | — | Optional in the schema. A volume with no @Volume(name:) argument authored is an
"anonymous" volume: swift-docc-render's Volume.vue then skips rendering
VolumeName entirely, and the volume's chapters appear with no volume-level heading. |
image |
string (format: reference(ImageRenderReference)) |
no | — | A reference-identifier string resolved against the page's references map; passed to
VolumeName's Asset child (only shown when name is also
present, since VolumeName is gated on v-if="name"). |
content |
array of RenderBlockContent |
no | — | Introductory content for the volume, rendered through ContentNode.vue inside
VolumeName — also only shown when name is present. |
chapters |
array of Chapter |
yes | — | One or more grouped lists of tutorials/articles; each becomes one Chapter.vue tile.
swift-docc's authoring-side model requires HasAtLeastOne<Volume, Chapter> at parse
time, so an authored @Volume always has at least one chapter in practice, though the wire
schema itself does not encode a minimum length. |
Chapter.name |
string | yes | — | Used as the chapter's heading and as the Vue :key in Volume.vue's
v-for. |
Chapter.content |
array of RenderBlockContent |
yes | — | Required in the schema (unlike the volume-level content); an empty array is valid
and is what swift-docc emits when a Chapter directive has no prose. |
Chapter.tutorials |
array of string (format: reference(TopicRenderReference)) |
yes | — | Ordered list of tutorial/article reference identifiers; resolved via
Volume.vue's lookupTopics() against the injected store's
references map before being handed to Chapter.vue as topics. |
Chapter.image |
string (format: reference(ImageRenderReference)) |
no | — | Per-chapter illustration reference, passed straight through to Chapter.vue. |
4. HTML/CSS mapping in DocC-Render output
Rendered DOM shape, assembled from LearningPath.vue and Volume.vue:
div.learning-path(fromLearningPath.vue) — wraps the whole "below the hero" region; containsdiv.main-container>div.secondary-content-container(the sticky side nav, hidden below the small breakpoint) anddiv.primary-content-container>div.content-sections-container.section.volume.content-section— one perVolumeRenderSection, the root element emitted byVolume.vue's template (.content-sectionis added by thev-forloop inLearningPath.vue, giving each top-level section rounded corners and inter-section spacing).div.volume-name(fromVolumeName.vue, only whennameis set) — containsAsset.image(optional),h2.name, and theContentNodeoutput forcontent.Chapter.tile× N (one per entry inchapters) — classtileis applied byVolume.vue'sv-for, andChapter.vueitself supplies whatever inner markup it uses for the chapter heading, blurb, and per-tutorial link tiles (out of scope for this page, sinceChapter.vueis not keyed bykind).
SCSS lives in each component's own <style scoped lang="scss"> block, all importing
docc-render/styles/_core.scss: LearningPath.vue (layout/spacing of the
container and the 200px sticky nav rail), Volume.vue (the .tile background
and padding), and VolumeName.vue (the centered name/blurb band). Key CSS custom
properties consumed:
--color-tutorials-overview-fillon.learning-path(falls back todark-color(fill)).--color-tutorials-overview-fill-secondaryon bothVolume.vue's.tileandVolumeName.vue's.volume-name(falls back todark-color(fill-secondary)) — this is what gives chapter tiles and the volume-name band their slightly-lighter-than-background panel color.--color-tutorials-overview-header-textonVolumeName.vue'sh2.name.--color-tutorials-overview-content-altonVolumeName.vue's.contentwrapper.
These custom properties are defined per color scheme in
src/styles/core/colors/_light.scss (e.g. --color-tutorials-overview-background
at line 187 through the surrounding --color-tutorials-overview-* block) and mirrored for
dark mode elsewhere in the same colors directory; TutorialsOverview.vue additionally
forces body:has(.tutorials-overview) { --color-text-background: ... } so the page
background stays dark even under a light OS/browser theme.
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
volume/VolumeRenderSection today.
5. Modern CSS-only alternative
PARTIAL
Current behavior in play spans two components. (1) Volume.vue mixes in
onIntersectViewport, which attaches an IntersectionObserver to the
volume's root element and calls store.setActiveVolume(this.name) whenever that element
crosses the viewport's vertical center while the user scrolls — a JS-computed "which volume is
currently in view" signal with no DOM attribute backing it directly. (2)
TutorialsNavigation.vue reads that same state.activeVolume value back out
of the shared TutorialsOverviewStore to decide, per named volume, whether its
TutorialsNavigationMenu disclosure should be collapsed; that menu also
toggles itself directly on click (@click.stop="onClick" emitting
select-menu/deselect-menu, which write back into the same store), and its
open/closed content is animated in/out via a custom <transition-expand> wrapping a
v-if="!collapsed" block.
The click-to-expand/collapse half of behavior (2) maps mechanically onto a native
<details>/<summary> pair: each named volume's nav entry becomes
a <details> whose <summary> is the toggle button, and the
browser's own open/closed attribute state (the presence or absence of the open attribute
on <details>) replaces the Vue collapsed prop entirely — no
store write needed just to expand/collapse a menu the user clicked. That removes the
select-menu/deselect-menu event-emit plumbing for the "user manually
toggled this menu" case. However, the verdict is partial, not fully applicable, for
two reasons grounded in the actual code above: first, "only one named volume's menu open at a time,
driven by scroll position" (behavior (1)) has no CSS-only equivalent — there is no native
selector that reacts to "which section is nearest the viewport center while scrolling," so the
IntersectionObserver + setActiveVolume call would still need to run in
script to keep the currently-visible volume's <details> element's open
attribute in sync as the user scrolls past sections without clicking anything; second, cross-menu
exclusivity (opening one collapses the others) is not automatic for independent
<details> elements unless they are given a shared name attribute (the
newer "exclusive accordion" behavior), which would need to be added explicitly and does not by itself
replicate the scroll-driven activation in reason one. So <details>/<summary>
would cleanly replace the click-driven expand/collapse state and its custom expand transition, but
the scroll-linked "active volume" tracking that also feeds that same state is not achievable as a
CSS-only mechanism with the sources examined here.