1. How swift-docc-render consumes this
contentAndMedia is one of three "article body layout" section kinds
(columns, contentAndMedia, fullWidth) that a
RenderNode's primaryContentSections / article body can contain.
The dispatch table lives in
BodyContent.vue,
which defines a local LayoutKind map and a componentFor(section)
method that switches on section.kind to pick a component to render via Vue's
dynamic <component :is="...">:
const LayoutKind = {
columns: 'columns',
contentAndMedia: 'contentAndMedia',
fullWidth: 'fullWidth',
};
...
componentFor(section) {
return {
[LayoutKind.columns]: Columns,
[LayoutKind.contentAndMedia]: ContentAndMedia,
[LayoutKind.fullWidth]: FullWidth,
}[section.kind];
},
propsFor(section) {
const { content, kind, media, mediaPosition } = section;
return {
...
[LayoutKind.contentAndMedia]: {
content,
media,
mediaPosition,
},
...
}[kind];
},
For kind: "contentAndMedia", BodyContent.vue passes exactly three
props through — content, media, and mediaPosition — to the
ContentAndMedia.vue
layout component. That component's template is small and delegates immediately to two
existing components — it does not implement any content or media rendering itself:
<template>
<div class="content-and-media" :class="classes">
<ContentNode :content="content" />
<Asset :identifier="media" />
</div>
</template>
content (an array of RenderBlockContent) is handed to
ContentNode.vue, the general block-content renderer used throughout
swift-docc-render. media is a plain string reference identifier
that is handed to
Asset.vue,
which resolves it against the render node's references map (via the
referencesProvider mixin) and dispatches to ImageAsset.vue or
VideoAsset.vue depending on the resolved reference's type.
mediaPosition ("leading" or "trailing") is turned into a
computed classes object (media-leading / media-trailing)
applied to the root <div class="content-and-media">, which purely a CSS
concern (flex-direction), not a structural one — see
section 4.
Note on scope: this is the "article body layout" flavor of contentAndMedia
(matching DocCArchive's vendored schema exactly — see section 3).
swift-docc's Swift model separately defines a same-named-kind
ContentAndMediaSection used for tutorial-overview "slides"
(Tutorial Table of Contents pages), which carries additional
layout, title, and eyebrow fields not present on the
wire schema DocCArchive vendors. swift-docc-render's tutorial overview views were not found
to consume that variant directly under the src/components/Tutorial/ or
src/views/ trees searched for this page; only the article-layout consumer above
was confirmed by direct grep and read of the source.
See also: The references map — how this and every other reference-dictionary lookup works across kinds.
2. Example JSON and rendered mockup
No real fixture matching the vendored ContentAndMedia schema (kind/content/media/mediaPosition
only) was found. DocCArchive's own fixtures (ExampleDocs.doccarchive,
SampleLibrary.doccarchive) only contain the string "contentAndMedia"
inside a minified render-side JS bundle (js/topic.c7f55345.js), not a JSON data
fixture. swift-docc's test suite has a fixture in
Tests/SwiftDocCTests/Model/ContentAndMediaSectionTests.swift, but it exercises the
tutorial-overview ContentAndMediaSection variant (extra layout,
title, eyebrow keys) rather than the article-layout schema vendored
into DocCArchive, so it was not reused verbatim. The example below is hand-written to satisfy
the vendored JSON Schema exactly.
{
"kind": "contentAndMedia",
"media": "media-1234",
"mediaPosition": "trailing",
"content": [
{
"type": "heading",
"level": 2,
"text": "Sensor fusion pipeline",
"anchor": "sensor-fusion-pipeline"
},
{
"type": "paragraph",
"inlineContent": [
{
"type": "text",
"text": "The pipeline combines readings from multiple sensors into a single, denoised estimate of device orientation."
}
]
}
]
}
Sensor fusion pipeline
The pipeline combines readings from multiple sensors into a single, denoised
estimate of device orientation.
[ media-1234 ]
mockup: content column leading, media column trailing (mediaPosition: "trailing")
3. Data sheet
Source: Sources/DocCArchive/Vendored/RenderNode.spec.json, schema object
#/components/schemas/ContentAndMedia, cross-checked against the generated
Components.Schemas.ContentAndMedia struct in
Sources/DocCArchive/generated/Types.swift.
| Field | Type | Required | Enum values / default | Note |
|---|---|---|---|---|
kind |
string | yes | "contentAndMedia" (single-value enum) |
Discriminator value; generated as KindPayload, a one-case String enum. |
media |
string (format: reference) |
yes | — | A RenderReferenceIdentifier-style key into the render node's top-level references map; generated as a plain Swift.String. |
mediaPosition |
string | yes | "leading", "trailing" |
Generated as MediaPositionPayload enum. No default at the schema level — swift-docc's tutorial-overview ContentAndMediaSection decoder separately falls back to .leading when absent, but that fallback belongs to the other Swift type, not this vendored wire schema, where the field is required. |
content |
array of RenderBlockContent |
yes | — | Arbitrary block content (headings, paragraphs, lists, etc.); rendered via ContentNode.vue. |
Fields present on swift-docc's tutorial-overview ContentAndMediaSection
Swift struct (layout, title, eyebrow) — see
ContentAndMediaSection.swift —
are not part of the vendored ContentAndMedia schema DocCArchive
generates types from, and are omitted from this table accordingly. Treat the table above,
not that Swift file, as authoritative for what a DocCArchive consumer actually receives on
the wire for this schema object.
4. HTML/CSS mapping in DocC-Render output
Rendered DOM shape, from ContentAndMedia.vue's template:
div.content-and-media— root element; also receives modifier classmedia-leadingormedia-trailingdepending on themediaPositionprop.- Child: whatever root element(s)
ContentNode.vuerenders for thecontentarray (adiv.contentwrapper style is targeted by the component's own scoped CSS via the.contentselector). - Child:
div.asset— rendered byAsset.vue, wrapping the resolvedImageAsset/VideoAssetcomponent for themediareference.
SCSS lives inline in ContentAndMedia.vue's <style scoped lang="scss">
block, importing the shared docc-render/styles/_core.scss partial. Key rules:
.content-and-media { display: flex; }, with&.media-leading { flex-direction: row-reverse; }and&.media-trailing { flex-direction: row; }— this is the entire mechanism by whichmediaPositionchanges the visual arrangement.- Column widths are computed with the SCSS helper
calculate-column-width():$col-width-content: calculate-column-width(7.5),$col-width-media: calculate-column-width(3.5), with the remainder ($col-offset) applied as a margin on.assetto push it away from.content. - A
@include breakpoints-from(medium)block vertically centers the two columns on medium/large viewports; a@include breakpoint(small)block collapses both toflex-direction: columnandwidth: 100%, always showing.contentbefore.assetregardless ofmediaPosition.
No CSS custom properties (--...) are consumed directly in this component; sizing
and spacing use SCSS variables/mixins from _core.scss
(e.g. $article-stacked-margin-small) resolved at build time, not runtime custom
properties.
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) — neither has any kind-specific handling for
contentAndMedia or any other render section today.
5. Modern CSS-only alternative
NOT APPLICABLE
Current behavior: ContentAndMedia.vue has no interactive state whatsoever. The
mediaPosition prop is read once at render time into a computed classes
object, which is a one-way, static mapping from the JSON payload to a CSS modifier class
(media-leading/media-trailing) on the root div. There is
no click handler, no toggle, no component data that changes after mount, and no
show/hide behavior to replace — the layout is fixed for the lifetime of the rendered page.
Because there is no client-side state transition to reproduce, none of the stateful-CSS
mechanisms (<details>/<summary>, checked radio +
sibling selector, :target, Popover API, <dialog>) apply here —
they all exist to hold or toggle state, and this component has none. The only thing that
varies is which of two static flex layouts is used, and that is already accomplished with
plain conditional class selection at render/build time (server- or static-render-time
class assignment), which requires no JavaScript or CSS pseudo-class trickery to begin with.
The one place modern CSS could simplify implementation (not behavior) is swapping the
calculate-column-width() SCSS helper for native CSS, e.g. sizing
.content/.asset with flex-basis percentages directly or
container queries instead of the SCSS breakpoint mixins — but that is a build-tooling/authoring
simplification, not a behavioral one, so it does not change the verdict.