node

tutorial

Wire value: "project"

Appears on: Tutorial (Project)

1. How swift-docc-render consumes this

A top-level RenderNode has a kind discriminator. For interactive tutorial pages (as opposed to symbol/article documentation pages) the wire value is the legacy string "project", even though every other layer of the stack now calls this concept a "tutorial." swift-docc's own decoder, RenderNode.Kind, accepts both spellings on decode but only ever encodes "project" (case tutorial = "project", line 256), so "project" is what actually appears in .doccarchive output on disk.

swift-docc-render's route-level dispatcher is views/Topic.vue. It keeps its own local map from a friendly key back to the wire string, and switches on topic.kind:

const TopicKind = {
  article: 'article',
  tutorial: 'project',
};
...
methods: {
  componentFor(topic) {
    const { kind } = topic;
    return {
      [TopicKind.article]: Article,
      [TopicKind.tutorial]: Tutorial,
    }[kind];
  },
  propsFor(topic) {
    const {
      hierarchy, kind, metadata, references, sections, identifier,
    } = topic;
    return {
      [TopicKind.tutorial]: {
        hierarchy, metadata, references, sections, identifierUrl: identifier.url,
      },
      ...
    }[kind];
  },
},

For kind: "project", Topic.vue renders components/Tutorial.vue and passes through exactly five props: hierarchy, metadata, references, sections, and identifierUrl (derived from identifier.url). Tutorial.vue's root template is:

<div class="tutorial">
  <NavigationBar
    v-if="!isTargetIDE"
    :technology="metadata.category"
    :chapters="hierarchy.modules"
    :topic="tutorialTitle || ''"
    :rootReference="hierarchy.reference"
    :identifierUrl="identifierUrl"
  />
  <main id="app-main" tabindex="0">
    <Section
      v-for="(section, index) in sections"
      :section="section"
      :key="index"
    />
    <BreakpointEmitter @change="handleBreakpointChange" />
  </main>
  <PortalTarget name="modal-destination" multiple />
</div>

The page's own sections array gets a second, local dispatch table (this is the node's per-section-kind lookup, distinct from the top-level RenderNode.kind dispatch above):

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;
  },
  props: {
    section: {
      type: Object,
      required: true,
      validator: section => ValidSectionTypes.has(section.kind),
    },
  },
};

(components/Tutorial.vue, lines 46-74.) Each entry in sections is therefore routed by its own kind (hero, tasks, assessments, or callToAction) to a dedicated component: theme/components/Tutorial/Hero.vue (imported via the theme/ alias, which the project's own jest.config.js maps straight back to src/components/Tutorial/Hero.vue), components/Tutorial/SectionList.vue, components/Tutorial/Assessments.vue, and components/Tutorial/CallToAction.vue. Sections with an unrecognized kind are silently dropped (the render function returns null).

The page chrome above the sections is components/Tutorial/NavigationBar.vue, which builds the "Primary"/"Secondary" chapter/section dropdowns from the same hierarchy.modules tree documented in the data sheet below (see section 4 and section 5 for how that dropdown holds its open/closed state).

What an author writes to produce this: swift-docc's authoring-side model class is Semantics/Tutorial/Tutorial.swift, backing the @Tutorial directive: a tutorial article's DocC catalog page opens with @Tutorial(time: ..., projectFiles: ...), followed by an @Intro child directive (becomes the hero section), one or more @Section/ @Steps child directives (become the tasks section's tutorial sections), and an optional @Assessments directive (becomes the assessments section). The compiler emits the resulting TutorialsPageRenderNode with kind: "project".

DocCArchive transform status: MyHTMLTransformer and MyMarkdownTransformer in Sources/DocCArchive/DocCArchive.swift both accept the full Components.Schemas.RenderNode enum (which includes the .TutorialsPageRenderNode case for this kind) but are still stub placeholders — the HTML transformer unconditionally returns a hardcoded <!-- what? --> comment and the Markdown transformer unconditionally returns an empty string. Neither has any kind-specific handling for tutorial pages today.

2. Example JSON and rendered mockup

Real fixture: swift-docc-render/tests/unit/imagePreloading/tutorial.json (committed test fixture, ~2000 lines) is a full, real kind: "project" RenderNode. The excerpt below is a trimmed-down subset of that exact fixture (same field shapes and several verbatim values — chapter/module/section references, hero copy, and the tasks/assessments/callToAction section kinds — with most of the tutorial's step content removed for length).

{
  "kind": "project",
  "schemaVersion": { "major": 1, "minor": 0, "patch": 0 },
  "identifier": {
    "url": "doc://com.example.Test/tutorials/TechnologyX/Tutorial",
    "interfaceLanguage": "swift"
  },
  "metadata": {
    "title": "Basic Augmented Reality App",
    "category": "Technology X",
    "categoryPathComponent": "TechnologyX",
    "role": "article"
  },
  "hierarchy": {
    "reference": "doc://com.example.Test/tutorials/TechnologyX",
    "modules": [
      {
        "reference": "doc://com.example.Test/tutorials/TechnologyX/Getting-Started",
        "projects": [
          {
            "reference": "doc://com.example.Test/tutorials/TechnologyX/Tutorial",
            "sections": [
              { "kind": "task", "reference": "doc://com.example.Test/tutorials/TechnologyX/Tutorial#Create-a-New-AR-Project" },
              { "kind": "assessment", "reference": "doc://com.example.Test/tutorials/TechnologyX/Tutorial#Check-Your-Understanding" }
            ]
          }
        ]
      }
    ]
  },
  "sections": [
    {
      "kind": "hero",
      "title": "Basic Augmented Reality App",
      "chapter": "Getting Started",
      "estimatedTimeInMinutes": 20,
      "xcodeRequirement": "Xcode 10 beta",
      "video": "video.mov",
      "backgroundImage": "hero_school.jpg",
      "projectFiles": "project.zip",
      "content": [
        { "type": "paragraph", "inlineContent": [ { "type": "text", "text": "The first tutorial." } ] }
      ]
    },
    {
      "kind": "tasks",
      "tasks": [
        {
          "anchor": "Create-a-New-AR-Project",
          "title": "Create a New AR Project",
          "contentSection": [],
          "stepsSection": []
        }
      ]
    },
    {
      "kind": "assessments",
      "anchor": "Check-Your-Understanding",
      "assessments": []
    },
    {
      "kind": "callToAction",
      "title": "Making an Augmented Reality App",
      "featuredEyebrow": "Article",
      "media": "arkit.png",
      "action": {
        "type": "reference",
        "isActive": true,
        "identifier": "doc://com.example.Test/tutorials/TechnologyX/TestTutorialArticle",
        "overridingTitle": "Read article"
      },
      "abstract": [ { "type": "text", "text": "This is an abstract for the hero." } ]
    }
  ],
  "references": {
    "doc://com.example.Test/tutorials/TechnologyX/TestTutorialArticle": {
      "kind": "article",
      "role": "article",
      "type": "topic",
      "title": "Making an Augmented Reality App",
      "url": "/tutorials/technologyx/testtutorialarticle"
    }
  }
}
Technology X  ·  Tutorials    [Getting Started ▾] [Basic Augmented Reality App ▾]
Getting Started
Basic Augmented Reality App

The first tutorial.

20 min · Xcode 10 beta · ⬇ project.zip

Create a New AR Project

(task steps content)

Check your understanding — assessment questions
[arkit.png] Making an Augmented Reality App
This is an abstract for the hero. → Read article

mockup: NavigationBar chrome, Hero (dark), a task section, an assessment section, and a callToAction footer — the four section kinds Tutorial.vue dispatches on.

3. Data sheet

Source: Sources/DocCArchive/Vendored/RenderNode.spec.json, schema object #/components/schemas/TutorialsPageRenderNode (one of the two oneOf branches of #/components/schemas/RenderNode), cross-checked against the generated Components.Schemas.TutorialsPageRenderNode struct in Sources/DocCArchive/generated/Types.swift (lines 2917-3024), which is reached via the Components.Schemas.RenderNode.TutorialsPageRenderNode(_:) enum case.

FieldTypeRequiredEnum values / defaultNote
hierarchy object (oneOf: Hierarchy) yes — Generated as a one-case HierarchyPayload enum wrapping Components.Schemas.Hierarchy. Has a required reference string and optional paths / modules arrays (the latter feeding NavigationBar.vue's chapter dropdown).
kind string yes "overview", "project", "article" Generated as KindPayload: String, CaseIterable. This page documents the "project" case specifically; "overview" and "article" are the tutorial-table-of-contents and free-standing-tutorial-article variants of the same struct and are out of scope here.
identifier ResolvedTopicReference yes — Contains the page's url and interfaceLanguage; Topic.vue reads identifier.url to build the identifierUrl prop.
title string no — Optional page title. In practice Tutorial.vue instead derives its displayed title from the hero section's own title field (tutorialTitle computed property).
sections array of RenderSection yes oneOf: IntroRenderSection, ArticleBodyRenderSection, CallToActionRenderSection, TasksSection, AssessmentsSection, VolumeRenderSection, ResourcesRenderSection Only the hero/intro (IntroRenderSection), tasks (TasksSection), assessments (AssessmentsSection), and callToAction (CallToActionRenderSection) kinds are consumed by Tutorial.vue's SectionComponents map (see section 1); the others are separately used by tutorial overview/table-of-contents pages.
references object, additionalProperties → RenderReference no — Generated as ReferencesPayload with an additionalProperties: [String: RenderReference1] dictionary. Keyed by the reference identifiers used throughout sections (e.g. topic links, images, code listings).
metadata TutorialsMetadata no — Only two documented properties in the vendored schema: category and categoryPathComponent (both strings). Tutorial.vue also reads metadata.availableLanguages/availableLocales at runtime, but those are not declared on the vendored TutorialsMetadata object.
schemaVersion SchemaVersion yes — { major, minor, patch } triple identifying the RenderNode JSON schema version the archive was generated with.

4. HTML/CSS mapping in DocC-Render output

Rendered DOM shape, from Tutorial.vue's template and its imported children:

SCSS lives inline in each component's <style scoped lang="scss"> block. Tutorial.vue's own block is minimal:

.tutorial {
  background-color: var(--colors-text-background, var(--color-tutorial-background));
}

--color-tutorial-background itself is a themeable custom property, defined per color scheme in src/styles/core/colors/_light.scss (var(--color-fill)) and src/styles/core/colors/_dark.scss (var(--color-fill-tertiary)) — so the page background automatically follows the site's light/dark theme without any component-level branching. NavigationBar.vue, Hero.vue, and the dropdown components each import the shared docc-render/styles/_core.scss partial and layer their own scoped rules (chapter list typography, dropdown positioning, hero background-image sizing, etc.) on top.

5. Modern CSS-only alternative

PARTIAL

Current behavior: the tutorial page itself (Tutorial.vue) has no interactive state of its own — it is a static list-to-component mapping over sections, same as the contentAndMedia case. But this render node's page chrome, NavigationBar.vue, does carry real client-side state: its chapter/section pickers delegate to DropdownCustom.vue (src/components/DropdownCustom.vue), which keeps an isOpen boolean in Vue component data() (initialized false), flips it in a toggleDropdown() click handler on a button.form-dropdown-toggle, and uses that boolean to add an is-open class to the dropdown's content panel and to set :aria-expanded="isOpen ? 'true' : 'false'" on the toggle button. A document-level click listener also closes the dropdown when a click lands outside this.$el.

That exact state/behavior — a labeled control that reveals a panel of options and closes again on a second interaction — is mechanically what <details>/<summary> is for. A native <details class="tutorial-dropdown"><summary>Basic Augmented Reality App</summary><ul>...chapters...</ul></details> would hold the open/closed state in the element's own open boolean attribute (toggled by the browser on <summary> click, no JS required), let CSS target the open state with the details[open] > summary / details:not([open]) .options selectors in place of the is-open class, and get outside-click-to-close behavior "for free" for the common case of a second click on the page (the browser does not auto-close on outside click the way DropdownCustom.vue's manual listener does, so an author relying purely on <details> would lose that one behavior, or would need a small amount of supplementary script — this is the reason for the "partial" verdict rather than "applicable"). Accessibility semantics also shift: native <details> exposes its own disclosure semantics to assistive tech, which is different from (not strictly better or worse than) the manually-authored aria-expanded/listbox/option roles DropdownCustom.vue and PrimaryDropdown.vue currently build by hand.

The rest of the node's own chrome — the Hero background image, the static section-to-component list, and the PortalTarget modal mount point — has no comparable native-CSS analog: the Hero's video modal is driven by a GenericModal component that itself could plausibly move to <dialog>, but that component is shared across many render-node kinds and is out of scope for this page; it is called out here only to be honest that "partial" reflects the navigation dropdown specifically, not every interactive surface a tutorial page happens to embed.