block

step

Wire value: "step"

Appears on: Tutorial (Project)

1. How swift-docc-render consumes this

Unlike most block-tier kinds, step is not handled inside the generic renderNode() dispatch table in ContentNode.vue — a grep of that file for "step"/BlockType.step turns up nothing. Instead, step nodes only ever appear inside the content array of a tutorial section, and a dedicated component, SectionSteps.vue, walks that array itself and special-cases the step type directly, via its own isStepNode helper at SectionSteps.vue#L164-L166:

isStepNode({ type }) {
  return type === 'step';
},

SectionSteps is registered as the Steps component in Section.vue#L28-L39 and mounted whenever a tutorial section's stepsSection content is non-empty (Section.vue#L18-L24). Its contentNodes computed property (SectionSteps.vue#L122-L149) reduces over the raw content array: any node where isStepNode is true is assigned the Step component (with a running stepNumber counter, its array index, numberOfSteps, and sectionNumber injected as props); every other node (interstitial prose, asides, images between steps) falls through to a plain ContentNode for generic block rendering. So the dispatch on the literal wire value "step" happens once, in this reduce, rather than in a switch statement.

Each matched node is rendered by Step.vue. Its template root is a <div class="step-container"> wrapping a <div class="step"> that holds a localized "Step {number}" label followed by a nested <ContentNode :content="content"> for the step's instructional body, and (conditionally) a second <ContentNode> for the caption (Step.vue#L11-L22). Alongside that, a sibling <div class="media-container"> (Step.vue#L25-L42) renders the step's media reference as an <Asset> and its code reference (paired with an optional runtimePreview) as a <MobileCodePreview> — but that container is CSS-hidden except at the small breakpoint, because on wider viewports the same media/code/runtimePreview triple is instead shown once, on the side, by the parent.

That "on the side" rendering is SectionSteps.vue's own job: it keeps a single visibleAsset ({ media, code, runtimePreview }) in component data, seeded from the first step (SectionSteps.vue#L93-L111), and swaps it via onFocus(key) (SectionSteps.vue#L186-L199) whenever the "active" step changes. The active step index (activeStep, passed down to every Step as currentIndex) is driven by scroll position: SectionSteps mixes in onIntersect and registers each step's DOM node as an IntersectionObserver target (getIntersectionTargets, SectionSteps.vue#L233-L235), with an observer rootMargin of -35% 0% -65% 0% (SectionSteps.vue#L76) that treats roughly the middle third of the viewport as the "focus band"; whichever step's container element crosses into that band calls onIntersect (SectionSteps.vue#L241-L255), which updates activeStep. Inside Step.vue, that prop feeds a computed isActive: ({ index, currentIndex }) => index === currentIndex (Step.vue#L116), which toggles the .focused class on the step's root <div class="step"> (Step.vue#L13-L18), producing the highlighted left-border treatment for whichever step the reader has scrolled to.

2. Example JSON and rendered mockup

No literal JSON fixture containing "type": "step" was found in Tests/DocCArchiveTests/Fixtures/ExampleDocs.doccarchive or SampleLibrary.doccarchive (both archives only cover reference documentation, not tutorials; grepping those trees for step only matches minified, bundled JS/CSS application asset filenames, not archive content data). Swift-DocC's own test suite does construct a RenderBlockContent.step(...) value, but as an in-memory Swift literal rather than JSON, in Tests/SwiftDocCTests/Model/RenderBlockContent+CapitalizationTests.swift:107:

let step = RenderBlockContent.step(.init(
  content: [.paragraph(.init(inlineContent: [.text("hello, world!")]))],
  caption: [.paragraph(.init(inlineContent: [.text("Step caption")]))],
  media: RenderReferenceIdentifier("Media"),
  code: RenderReferenceIdentifier("Code"),
  runtimePreview: RenderReferenceIdentifier("Preview")
)).capitalizingFirstWord()

The JSON example below is hand-written, matching that fixture's field values and the schema confirmed in §3.

{
  "type": "step",
  "content": [
    {
      "type": "paragraph",
      "inlineContent": [
        { "type": "text", "text": "Hello, world!" }
      ]
    }
  ],
  "caption": [
    {
      "type": "paragraph",
      "inlineContent": [
        { "type": "text", "text": "Step caption" }
      ]
    }
  ],
  "media": "Media",
  "code": "Code",
  "runtimePreview": "Preview"
}

An author produces this by writing a @Step directive inside a @Steps group:

@Steps {
  @Step {
    Hello, world!

    > Step caption

    @Image(source: media.png, alt: "...")
    @Code(name: "Code", file: main.swift)
  }
}

Per swift-docc's directive parser (Sources/SwiftDocC/Semantics/Tutorial/Tasks/Steps/Step.swift:89-105), the first paragraph becomes content, an immediately following second paragraph (typically a block quote in practice) becomes caption, and at most one media directive plus one @Code directive supply media/code; runtimePreview is populated later by the compiler when it can produce a live preview of the referenced code file, not by anything the author writes directly.

Step 1

Hello, world!

Step caption

Mockup: the .focused left border (blue bar) only appears on whichever step is currently scrolled into the middle-third "focus band"; the sibling media/code panel this step's media/code/runtimePreview would drive is rendered once, to the side, by SectionSteps.vue, not shown per-step here except on small screens.

3. Data sheet

Authoritative source: Sources/DocCArchive/Vendored/RenderNode.spec.json, schema object Step (around line 1069), referenced from the RenderBlockContent discriminated union; cross-checked against the generated Components.Schemas.Step struct in Sources/DocCArchive/generated/Types.swift (around lines 4633–4672). No standalone doccArchiveType beyond this generated Components.Schemas.Step was found by grepping Types.swift for Step.

FieldTypeRequired?Enum values / defaultNote
typestringyes"step" (fixed enum, one value)Discriminator tag; generated as Components.Schemas.Step._TypePayload, a single-case String-backed enum.
contentarray of RenderBlockContentyes (schema); generated Swift is non-optional [RenderBlockContent]—The step's instructional body. Swift-docc's authoring model restricts this in practice to a single paragraph plus, optionally, nested asides, but the wire schema itself permits arbitrary block content.
captionarray of RenderBlockContentlisted as required in the JSON schema, but swift-docc's own decoder treats it as optional and defaults to [] if absent (RenderBlockContent.swift decoding switch, case .step)default []Discrepancy worth flagging: the vendored schema's required list includes caption, but the hand-written Codable conformance in swift-docc uses decodeIfPresent(...) ?? [] for it — so a wire payload omitting caption entirely still decodes successfully on the swift-docc side even though the JSON Schema says it must be present.
mediastring, nullablenodefault null/absentA RenderReferenceIdentifier (opaque string key) into the RenderNode's top-level references map; resolved by <Asset :identifier="media"> in Step.vue/SectionSteps.vue. swift-docc's Swift struct always encodes this key (even when nil, it is written as JSON null) — it is never simply omitted.
codestring, nullablenodefault null/absentA RenderReferenceIdentifier pointing at the step's associated source file; drives the <MobileCodePreview>/<CodePreview> panel. Also always encoded, even when nil.
runtimePreviewstring, nullablenodefault null/absentA RenderReferenceIdentifier for a rendered preview asset of the step's code, shown as an overlay <Asset> inside the code preview. Also always encoded, even when nil.

See also: The references map — how this and every other reference-dictionary lookup works across kinds.

Cross-checking swift-docc's authoring-side Swift model at RenderBlockContent.swift#L486-L506 (public struct TutorialStep: Equatable): its initializer gives media, code, and runtimePreview a default of nil, but content and caption are both plain, non-optional [RenderBlockContent] parameters with no default — matching the generated Swift struct's shape, and explaining why the encoder (RenderBlockContent.swift#L1186-L1191) unconditionally writes all five keys. The enum case itself is declared at RenderBlockContent.swift:54 (case step(TutorialStep)).

DocCArchive transform status: Not yet implemented. MyHTMLTransformer and MyMarkdownTransformer in Sources/DocCArchive/DocCArchive.swift are still stub placeholders (HTMLRaw("<!-- what? -->") and return "" respectively) and do not branch on RenderBlockContent/Components.Schemas.Step at all, so a step block passed through either transformer today produces no step-specific output.

4. HTML/CSS mapping in DocC-Render output

Per step, the DOM shape (from Step.vue's template) is:

The wider, non-mobile media/code panel lives outside Step.vue entirely, in SectionSteps.vue's template: div.steps > div.asset-container.asset-wrapper (via BackgroundTheme), holding either an Asset (.step-asset) or a CodePreview, whichever the currently-focused step's visibleAsset supplies.

Styling is split across two scoped SCSS blocks, both lang="scss" in the same files:

CSS custom properties consumed (from src/styles/core/colors/_light.scss and friends):

Non-custom-property SCSS variables also feed in: $step-padding-horizontal (2rem, defined in src/styles/core/_vars.scss) sets the card's horizontal padding, and $step-border-width sets the width of the ::before accent bar.

5. Modern CSS-only alternative

Partial

Current behavior: the "active step" highlight is not a click-driven toggle but a scroll-position computation. SectionSteps.vue registers each step element with an IntersectionObserver whose rootMargin is -35% 0% -65% 0% (SectionSteps.vue#L76), so only elements crossing the vertical middle third of the viewport fire; the observer callback (onIntersect) writes a single reactive activeStep index in component data, which is handed down as the currentIndex prop to every Step, where isActive: index === currentIndex toggles the .focused class (Step.vue#L116). The same onFocus call also swaps visibleAsset, which is what actually keeps the media/code panel in sync with the highlighted step.

This is a case where a purely declarative CSS mechanism can replace part of the behavior but not all of it. CSS Scroll-driven Animations' view() timeline (an animation-timeline: view() tied to each .step element, animating e.g. its border-color/opacity as the element crosses a declared view-timeline-inset band) can mechanically reproduce the .focused visual toggle without any IntersectionObserver or Vue reactive state at all — the browser itself tracks each element's position in the scrollport and drives the animation, which is exactly the "highlight whichever card is in the middle third" effect the JS produces today. That covers the .step card's own highlight.

What it cannot cover: the side-panel synchronization. The visibleAsset swap is cross-element state — the currently-scrolled-to step's media/code/runtimePreview must be reflected in a different DOM subtree (the sticky .asset-container that lives outside any individual step). No scroll-linked CSS mechanism can select "the sibling asset panel corresponding to whichever card is currently in view" and swap its content purely in CSS: :has() only looks at descendants/siblings within a single selector chain relative to a fixed anchor, not "whichever of N possible panels matches the one whose trigger is currently intersecting," and there is no CSS construct that reads a scroll-timeline position in one element and uses it to pick which of several unrelated elements to display. That part of the behavior remains inherently JavaScript-driven (or would require, at minimum, per-step CSS anchor-positioning + :target-style plumbing that swift-docc-render's markup does not currently provide hooks for), which is why this is scored "Partial" rather than "Applicable."