section

tasks

Wire value: "tasks"

Appears on: Tutorial (Project)

1. How swift-docc-render consumes this

tasks is a top-level, article/tutorial-tier RenderSection.kind (see RenderSectionKind at swift-docc's Sources/SwiftDocC/Model/Rendering/RenderSection.swift:17). It appears in the sections array of a RenderNode whose top-level kind is "tutorial", alongside sibling sections such as hero, assessments, and callToAction. In swift-docc it is produced by TutorialSectionsRenderSection, whose kind defaults to .tasks and which wraps an array of Section values (each carrying title, contentSection, stepsSection, and anchor).

On the render side, the dispatch table lives in src/components/Tutorial.vue, which is the top-level page component for tutorial RenderNodes (analogous to ContentNode.vue's dispatch for block/inline content, but for whole sections). It builds a literal SectionComponents map keyed by each section's kind string and iterates sections, instantiating whichever component matches:

const SectionComponents = {
  assessments: Assessments,
  hero: Hero,
  tasks: SectionList,
  callToAction: CallToAction,
};
const ValidSectionTypes = new Set(Object.keys(SectionComponents));

const TutorialSection = {
  name: 'TutorialSection',
  render: function render(createElement) {
    const { kind, ...props } = this.section;
    const component = SectionComponents[kind];
    return component ? createElement(component, { props }) : null;
  },
  ...
};

So kind: "tasks" is routed to src/components/Tutorial/SectionList.vue, which receives the section's tasks array as a prop of the same name and renders a <Section> (from Tutorial/Section.vue) for every entry, spreading each Task/Section object's fields as props and using section.anchor as the DOM id and index + 1 as the displayed sectionNumber:

<div class="sections">
  <Section
     v-for="(section, index) in tasks"
     v-bind="section"
     :key="index"
     :id="section.anchor"
     :sectionNumber="index + 1"
     :isRuntimePreviewVisible="isRuntimePreviewVisible"
     @runtime-preview-toggle="onRuntimePreviewToggle"
  />
</div>

Each individual Tutorial/Section.vue wraps its content in a LinkableElement (aliased LinkableSection) keyed by the task's anchor — this is what lets the tutorial navigation bar and in-page links jump directly to a given task — and delegates contentSection to SectionIntro.vue (splitting the first entry out as the "intro" content/media block and any remaining entries as expandedSections) and stepsSection to SectionSteps.vue when non-empty.

2. Example JSON and rendered mockup

No fixture archive in Tests/DocCArchiveTests/Fixtures/ (ExampleDocs.doccarchive, SampleLibrary.doccarchive) contains tutorial RenderNode JSON with a tasks section — both only ship the compiled tutorials-overview CSS/JS bundle, not symbol/tutorial JSON with this section. A grep of swift-docc's Tests/SwiftDocCTests/ for a raw JSON literal containing "tasks" also found nothing; the closest authoritative fixture is a Swift struct-literal test in Tests/SwiftDocCTests/Model/RenderNodeSerializationTests.swift (testRoundTrip), which builds a TutorialSectionsRenderSection from two TutorialSectionsRenderSection.Section values with real field shapes (a contentAndMedia content-layout entry plus a mix of paragraph, step, and aside block content in stepsSection). The example below is a synthesized JSON encoding built directly from that Swift fixture's field values and from the TasksSection/Task/ContentAndMedia/Step schema objects in RenderNode.spec.json.

{
  "kind": "tasks",
  "tasks": [
    {
      "anchor": "create-a-new-ar-project",
      "title": "Create a new AR project",
      "contentSection": [
        {
          "kind": "contentAndMedia",
          "mediaPosition": "leading",
          "media": "screenshot1.png",
          "content": [
            {
              "type": "paragraph",
              "inlineContent": [
                { "type": "text", "text": "Let's get started building the Augmented Reality app." }
              ]
            }
          ]
        }
      ],
      "stepsSection": [
        {
          "type": "paragraph",
          "inlineContent": [
            { "type": "text", "text": "After you download Xcode, create a project." }
          ]
        },
        {
          "type": "step",
          "content": [
            { "type": "paragraph", "inlineContent": [{ "type": "text", "text": "Lorem ipsum" }] }
          ],
          "caption": [
            { "type": "paragraph", "inlineContent": [{ "type": "text", "text": "Caption" }] }
          ],
          "media": "screenshot2.png"
        },
        {
          "type": "aside",
          "style": "Note",
          "content": [
            { "type": "paragraph", "inlineContent": [{ "type": "text", "text": "Lorem ipsum dolor emit." }] }
          ]
        }
      ]
    }
  ]
}

1  Create a new AR project

[leading media: screenshot1.png]  Let's get started building the Augmented Reality app.

  1. After you download Xcode, create a project.
  2. Lorem ipsum (caption: "Caption", with screenshot2.png)
Note: Lorem ipsum dolor emit.

3. Data sheet

Source: Sources/DocCArchive/Vendored/RenderNode.spec.json (schema objects TasksSection and Task), cross-checked against the generated Components.Schemas.TasksSection / Components.Schemas.Task in Sources/DocCArchive/generated/Types.swift.

FieldTypeRequiredEnum / defaultNote / source
kindstringyesenum: ["tasks"]Discriminator; generated as TasksSection.KindPayload, a single-case enum.
tasksarray of Taskyes—The ordered list of tutorial task sections rendered on the page; generated as [Components.Schemas.Task].
Task.anchorstringyes—Deep-link identifier used as the section's DOM id (:id="section.anchor" in SectionList.vue).
Task.titlestringyes—Displayed as the task's heading text in SectionIntro.vue.
Task.contentSectionarray of ContentLayoutyesContentLayout is a oneOf: FullWidth, ContentAndMedia, ColumnsIntro/body content for the task; first entry is split out as the "intro" media block by Section.vue's introProps computed property.
Task.stepsSectionarray of RenderBlockContentyeslarge oneOf (paragraph, step, aside, codeListing, etc.)The ordered walkthrough steps; rendered by SectionSteps.vue only when non-empty (v-if="stepsSection.length > 0").

Note on naming: swift-docc's Swift API names the section type TutorialSectionsRenderSection and its element type TutorialSectionsRenderSection.Section, but the OpenAPI/JSON schema (and therefore the generated DocCArchive types) names them TasksSection and Task respectively — the wire-level field names (anchor, title, contentSection, stepsSection) are identical between the two, this is purely a type/schema naming difference between the Swift authoring API and the JSON wire format.

4. HTML/CSS mapping in DocC-Render output

SectionList.vue renders a single wrapper <div class="sections">, styled by a scoped SCSS block in the same file (src/components/Tutorial/SectionList.vue) using the breakpoint-content mixin from docc-render/styles/_core.scss and a breakpoint(small) override that zeroes the margin and sets width: 100%.

Each task is then an instance of Tutorial/Section.vue, whose template root is <LinkableSection class="section" :anchor="anchor" :title="introProps.title"> — LinkableElement.vue renders that as a plain <div :id="anchor"> (the tag is configurable via a tag prop, default div), so the DOM id for deep-linking into a task comes directly from Task.anchor. The section's own scoped style (.section { padding-top: $tutorial-section-spacing-single-side; }) only adds top spacing.

Inside each section, SectionIntro.vue renders <div class="intro-container"> containing a responsive Row/Column grid (classes intro, intro-{n}, left, right, media, expanded-intro) for the task's contentSection, and — only when stepsSection is non-empty — SectionSteps.vue renders <div class="steps"> with nested content-container, asset-container, asset-wrapper, and step-asset elements for the numbered walkthrough and its accompanying media/code.

LinkableElement.vue additionally registers each anchor with the page's navigation store (store.addLinkableSection) and uses an IntersectionObserver (onIntersect mixin) to report scroll-visibility back to that store, which drives the tutorial's "on this page" navigation highlighting — this is state/behavior, not styling, but it is keyed off the same anchor value that produces the section's CSS id.

5. Modern CSS-only alternative

Not applicable

The actual JS/Vue behavior here is twofold and neither part is a simple visual toggle that a pure-CSS mechanism would replace: (1) Tutorial.vue's SectionComponents lookup is a one-time, build/render-time dispatch from a JSON discriminator string to a Vue component — it happens once when the page is constructed, not in response to user interaction, so there is no "state" for a :checked sibling selector, <details>, or :target to hold; and (2) the runtime-interactive piece that does exist — LinkableElement.vue's IntersectionObserver-driven scroll tracking that updates navigation-highlight state in store.updateLinkableSection — requires observing scroll intersection ratios continuously and pushing that into a separate, cross-component navigation-bar view; there is no scroll-linked native primitive available at this pin (this predates broad support for animation-timeline: view()/scroll-driven animations, and even that mechanism animates CSS properties rather than driving arbitrary cross-component JS state, e.g. which nav item shows as "active" in NavigationBar.vue). The tasks section itself is otherwise a static list container (SectionList.vue) with no visibility toggle, tab, or disclosure state of its own — each child Task is always fully rendered — so there is no interactive behavior at this kind's own level to replace with <details>/<summary>, radio-driven :checked, :target, the Popover API, or <dialog>.