1. How swift-docc-render consumes this
sampleDownload is one of the cases in swift-docc's Swift-side
RenderSectionKind enum (see swiftCaseSite,
Sources/SwiftDocC/Model/Rendering/RenderSection.swift line 20), but on the wire it is
not emitted as a member of a RenderNode's generic sections array the way
block/inline content kinds are. Instead, swift-docc's RenderNodeTranslator assigns the decoded
payload directly onto a fixed, named top-level property of a symbol/article page: sampleCodeDownload
(node.sampleDownload = .init(action: …) at
RenderNodeTranslator.swift#L846-L866).
Correspondingly, a literal string search for "sampleDownload" and for sampleCodeDownload
across swift-docc-render/src/components/ and src/views/ turns up nothing in
ContentNode.vue's block/inline dispatch table (that table is irrelevant here — this is not a
block-content kind) and nothing in a section-kind dispatch table either. The only consumer is
components/DocumentationTopic.vue, which reads the fixed prop sampleCodeDownload
directly (no kind-keyed lookup at all):
<div v-if="sampleCodeDownload">
<DownloadButton
class="sample-download"
:action="sampleCodeDownload.action"
linksToAsset
/>
</div>
(DocumentationTopic.vue#L64-L70).
The prop is declared as a plain, optional Object
(DocumentationTopic.vue#L346-L349),
and it also participates in the hero's "how much header content is there" tally used to decide the
minimized-hero title style
(DocumentationTopic.vue#L520-L527).
DownloadButton is a local alias for CallToActionButton.vue
(import CallToActionButton from './CallToActionButton.vue'; … DownloadButton: CallToActionButton, at
DocumentationTopic.vue#L205-L251)
— the same base component used by the unrelated callToAction section kind. It resolves the
action (a RenderInlineContent.reference) through
DestinationDataProvider to obtain a concrete url/title pair, then
renders a ButtonLink:
<DestinationDataProvider v-if="action" :destination="action" v-slot="{ url, title }">
<ButtonLink :url="normalizeUrl(url)" :isDark="isDark" :linksToAsset="linksToAsset">
{{ title }}
</ButtonLink>
</DestinationDataProvider>
(CallToActionButton.vue#L11-L20).
Because linksToAsset is passed as true from DocumentationTopic.vue,
normalizeUrl() runs the resolved URL through normalizePath/normalizeRelativePath
so that same-bundle asset downloads resolve correctly relative to the archive's base path
(CallToActionButton.vue#L35-L39).
ButtonLink.vue then either renders an internal Reference component (if a
url is present) or a plain <button>, with root class button-cta
(ButtonLink.vue#L11-L20).
A sibling property, downloadNotAvailableSummary (an array of RenderBlockContent),
is rendered as an inline Aside kind="note" just below the description when the sample project
download isn't available for the current platform variant
(DocumentationTopic.vue#L111-L116).
It is a separate, independently-optional field from sampleCodeDownload, not part of the
SampleDownload payload itself.
DocCArchive's own transform side: MyHTMLTransformer and MyMarkdownTransformer
(Sources/DocCArchive/DocCArchive.swift lines 242-254) are still stub placeholders — the HTML
transformer unconditionally returns a hardcoded HTML comment and the Markdown transformer returns an empty
string, regardless of input. Neither one reads sampleCodeDownload (or any other field) today, so
this kind does not yet flow through DocCArchive's transform in any functional way.
2. Example JSON and rendered mockup
Real fixture: swift-docc/Tests/SwiftDocCTests/Rendering/Rendering Fixtures/sample-download-symbol.json,
exercised by SampleDownloadTests.testDecodeSampleDownloadSymbol()
(swift-docc/Tests/SwiftDocCTests/Rendering/SampleDownloadTests.swift lines 17-48). The excerpt
below is the fixture's sampleCodeDownload value together with the matching entry from its
references dictionary (key "doc://org.swift.docc.example/downloads/sample.zip").
{
"sampleCodeDownload": {
"action": {
"type": "reference",
"identifier": "doc://org.swift.docc.example/downloads/sample.zip",
"isActive": true,
"overridingTitle": "Download"
}
},
"references": {
"doc://org.swift.docc.example/downloads/sample.zip": {
"type": "download",
"identifier": "project.zip",
"url": "/downloads/project.zip",
"checksum": "ad4adacc8ad53230b59d"
}
}
}
3. Data sheet
| Field | Type | Required | Enum / default | Note |
|---|---|---|---|---|
action |
Reference (a RenderInlineContent variant) |
yes | — | Only field of the SampleDownload schema object
(Sources/DocCArchive/Vendored/RenderNode.spec.json lines 3238-3248; generated
Components.Schemas.SampleDownload struct, Sources/DocCArchive/generated/Types.swift
lines 7080-7094). Its own required sub-fields are type (enum "reference"),
isActive (boolean), and identifier (string, a key into the RenderNode's
references map); overridingTitle and overridingTitleInlineContent are
optional (Reference schema, spec.json lines 1302-1330). |
sampleCodeDownload |
SampleDownload (single object, not array) |
no | — | This is the actual property name on the wire and in the generated struct — there is no
kind: "sampleDownload" discriminator anywhere in the JSON. It lives directly on
DocumentationRenderNode (spec.json lines 2056-2138, property at line 2135; generated
Components.Schemas.DocumentationRenderNode.sampleCodeDownload: SampleDownload? at
generated/Types.swift line 5375). The Swift-side RenderSectionKind.sampleDownload
case and the SampleDownloadSection struct (RenderNode.swift's
sampleDownload stored property, decoded/encoded under the same JSON key
sampleCodeDownload) exist for the diffing/AnyRenderSection machinery, not because
this is emitted as an array member alongside hero/declarations/etc. |
downloadNotAvailableSummary |
array of RenderBlockContent |
no | — | Sibling property on DocumentationRenderNode (spec.json lines 2138-2143); independent of
sampleCodeDownload, shown when a per-platform sample project isn't available. |
references["…"].type |
string | yes | enum: "download", "externalLocation" |
DownloadRenderReference schema (spec.json lines 1882-1904); the reference entry that
action.identifier points at. Generated as
Components.Schemas.DownloadRenderReference (generated/Types.swift lines
619-651). |
references["…"].checksum |
string | no (absent from schema's required list) |
— | Quirk: the generated Swift struct declares checksum: Swift.String as
non-optional (generated/Types.swift line 631), even though the JSON Schema
marks it optional and swift-docc's own SampleDownloadTests.testExplicitNullChecksum() asserts
that swift-docc can produce "checksum":null on the wire. A DocCArchive consumer decoding a
real archive whose download reference omits or nulls checksum would fail to decode with the
currently generated types. |
See also: The references map — how this and every other reference-dictionary lookup works across kinds.
Sources: Sources/DocCArchive/Vendored/RenderNode.spec.json (schema objects SampleDownload,
lines 3238-3248, and DownloadRenderReference, lines 1882-1904);
Sources/DocCArchive/generated/Types.swift (structs at lines 5375, 7080-7094, and 619-651); swift-docc
struct SampleDownloadSection at
SampleDownloadSection.swift#L16-L44.
Note: this repo's vendored spec is pinned to a different upstream commit
(5915e66d…, "6.3-nightly" per Sources/DocCArchive/VendorVersion.swift) than the
swift-docc checkout used for steps 1 and 3 of this page's sourcing, which is the likely source of the
optionality mismatch noted above.
4. HTML/CSS mapping in DocC-Render output
Rendered markup, from outermost to innermost:
div(unclassed wrapper, only presentv-if="sampleCodeDownload") — direct child ofDocumentationHero's slot content inDocumentationTopic.vue.CallToActionButtonroot:<DestinationDataProvider>— a logic-only wrapper component, renders no element of its own.a.button-cta.sample-downloadorbutton.button-cta.sample-download— the actual clickable element, produced byButtonLink.vue(root classbutton-cta) with the caller-suppliedclass="sample-download"merged on by Vue's automatic class binding. Renders as an<a>(via the internalReferencecomponent) when aurlresolves, otherwise a plain<button>.
SCSS: the .sample-download rule itself only sets layout spacing and lives inline in
DocumentationTopic.vue's <style scoped> block
(DocumentationTopic.vue#L944-L946,
margin-top: 20px;). All visual styling of the button chrome itself comes from
.button-cta in ButtonLink.vue's own <style scoped lang="scss"> block
(ButtonLink.vue#L51-L98).
CSS custom properties consumed there: --colors-button-light-background /
--color-button-background, --color-button-border, --button-border-radius,
--button-border-style, --button-border-width, --colors-button-text /
--color-button-text, --colors-button-light-backgroundActive /
--color-button-background-active, --colors-button-light-backgroundHover /
--color-button-background-hover, and, for the (unused by this button) is-dark
variant, --colors-button-dark-background and its active/hover counterparts.
5. Modern CSS-only alternative
Not applicable
Current JS/Vue behavior: nothing in this chain holds client-side UI state. DocumentationTopic.vue
conditionally mounts the wrapper <div> with a plain v-if="sampleCodeDownload"
(a build-time/render-time presence check on a prop, not a runtime toggle a user can flip);
CallToActionButton.vue and ButtonLink.vue are pure presentational components with no
data(), no v-show, and no click handler that changes local state — ButtonLink
renders either a real <a> (normal browser navigation to the download URL) or an inert
<button> if no URL resolved. DestinationDataProvider only resolves a reference
identifier to a URL/title pair at render time; it does not introduce interactivity either.
Because there is no interactive state (no expand/collapse, no tab switch, no modal open/close) to reproduce,
there is no native mechanism — <details>, radio-driven :checked, :target,
Popover API, <dialog>, :has(), container queries, or view-transitions — that
applies here. This section is a single conditionally-rendered link/button whose only "logic" is presence-or-absence
of an optional field, which plain HTML (element present or not present in the response) already expresses with
zero client-side behavior to replace.