block

orderedList

Wire value: "orderedList"

Appears on: Documentation Topic, Tutorial (Project), Tutorial Article

1. How swift-docc-render consumes this

Block content is dispatched by the renderNode() function in ContentNode.vue, which switches on a BlockType constant map. orderedList is registered at ContentNode.vue#L42 (orderedList: 'orderedList'), alongside unorderedList at ContentNode.vue#L46. The BlockType.orderedList case is handled directly, with no dedicated Vue child component, at ContentNode.vue#L297-L304:

case BlockType.orderedList:
  return createElement('ol', {
    attrs: {
      start: node.start,
    },
  }, (
    renderListItems(node.items)
  ));

renderListItems is a small shared helper (used by both orderedList and unorderedList) defined at ContentNode.vue#L126-L130:

const renderListItems = items => items.map(item => (
  createElement('li', {}, (
    renderChildren(item.content)
  ))
));

So an orderedList block becomes a plain HTML <ol> element (no wrapper component, no scoped Vue template), with each entry in node.items becoming an <li> whose children are recursively rendered through renderChildren — meaning a list item's content array can hold arbitrary nested block content (paragraphs, code listings, even nested lists). The wire field node.start is passed straight through as the native HTML start attribute on the <ol>; when it is undefined the attribute is simply omitted and the browser's own default numbering (starting at 1) takes over.

This differs from the sibling case, BlockType.unorderedList (ContentNode.vue#L354-L370), which first checks whether the list qualifies as a "task list" (at least one item carries a boolean checked property, validated by TaskList.vue#L28-L34) and, if so, delegates to the dedicated TaskList component instead of a plain <ul>. There is no equivalent task-list branch for orderedList: an ordered list is always rendered as a bare <ol>/<li> tree, even if an item happened to carry a checked field.

Two other places in the same file treat orderedList identically to unorderedList purely for tree-walking purposes (not rendering): the generic content-tree mapper at ContentNode.vue#L576-L584 and the depth-first forEach walker at ContentNode.vue#L629-L632, both of which recurse into item.content for every item in node.items — used for things like collecting all references/links contained anywhere in a content tree.

2. Example JSON and rendered mockup

No JSON fixture containing a "type": "orderedList" block was found in either Tests/DocCArchiveTests/Fixtures/ExampleDocs.doccarchive or SampleLibrary.doccarchive in this repository (a grep for orderedList in those fixture trees only matches the bundled, minified js/39.06467a79.js application bundle, not archive content data), nor as a JSON/wire-literal fixture in swift-docc's test suite — the closest matches (Tests/SwiftDocCTests/Model/RenderBlockContent+CapitalizationTests.swift, Tests/SwiftDocCTests/Model/SemaToRenderNodeTests.swift) construct RenderBlockContent.orderedList(.init(items: ...)) as in-memory Swift values and assert on them directly, never round-tripping through literal JSON. The example below is hand-written to match the schema confirmed in §3.

{
  "type": "orderedList",
  "start": 3,
  "items": [
    {
      "content": [
        {
          "type": "paragraph",
          "inlineContent": [
            { "type": "text", "text": "Configure the build settings." }
          ]
        }
      ]
    },
    {
      "content": [
        {
          "type": "paragraph",
          "inlineContent": [
            { "type": "text", "text": "Run the target on a simulator." }
          ]
        }
      ]
    },
    {
      "content": [
        {
          "type": "paragraph",
          "inlineContent": [
            { "type": "text", "text": "Verify the output in the console." }
          ]
        }
      ]
    }
  ]
}

An author produces this by writing a Markdown numbered list starting above 1, e.g.:

3. Configure the build settings.
4. Run the target on a simulator.
5. Verify the output in the console.
  1. Configure the build settings.
  2. Run the target on a simulator.
  3. Verify the output in the console.

Mockup: a native <ol start="3">, exactly as ContentNode.vue emits it — numbering, markers, and indentation are 100% native HTML/CSS list rendering, with no JavaScript involved after the initial createElement('ol', ...) call.

3. Data sheet

Authoritative source: Sources/DocCArchive/Vendored/RenderNode.spec.json (schema object OrderedList, referencing ListItem), cross-checked against the generated Components.Schemas.OrderedList / Components.Schemas.ListItem structs in Sources/DocCArchive/generated/Types.swift (around lines 4357–4437).

FieldTypeRequired?Enum values / defaultNote
typestringyes"orderedList" (fixed enum, one value)Discriminator tag; generated as Components.Schemas.OrderedList._TypePayload, a single-case String-backed enum.
startintegernono schema default stated; generated Swift property is Swift.Int?Starting index for the list's numbering. Per swift-docc's own model (RenderBlockContent.swift encoder, around line 1179–1182 of the pinned commit) this key is present in the JSON only when the authoring-side startIndex differs from its default of 1; when omitted, swift-docc-render's <ol start="undefined"> is dropped by Vue and the browser numbers from 1.
itemsarray of ListItemyes—One entry per authored list line; order is rendering order, top to bottom.
ListItem.contentarray of RenderBlockContentyes—Arbitrary nested block content for that item (paragraphs, code listings, nested lists, etc.).
ListItem.checkedbooleanno—Present on the shared ListItem shape for task-list support, but swift-docc-render's BlockType.orderedList branch never inspects it (only the unorderedList branch's task-list check does) — so on an ordered list this field, even if present, has no rendering effect.

Cross-checking swift-docc's authoring-side Swift model (not the wire schema, but useful color): the in-memory struct at RenderBlockContent.swift#L461-L472 (local path: Sources/SwiftDocC/Model/Rendering/Content/RenderBlockContent.swift:461) names the field startIndex: UInt with an explicit default of 1, and the case itself is declared at RenderBlockContent.swift:49 (case orderedList(OrderedList)). The Codable implementation only emits the wire key start when startIndex != 1 (RenderBlockContent.swift lines ~1179–1182), and decodes it back with container.decodeIfPresent(UInt.self, forKey: .start) ?? 1 (line ~1074). The vendored JSON schema's looser Swift.Int? (no explicit default, no non-negativity constraint) is the authoritative wire-level contract for this repository, per the task's data-sheet precedence — but the swift-docc authoring model's implicit "1 unless otherwise stated" default is worth stating explicitly since the JSON schema alone doesn't encode it.

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

4. HTML/CSS mapping in DocC-Render output

Root element: a plain <ol> (no wrapper <div>, no CSS class, no id), with an optional native start attribute, produced inline by ContentNode.vue's createElement('ol', ...) — there is no dedicated OrderedList.vue component the way there is a Row.vue or TabNavigator.vue for other block kinds. Each item is a plain <li>, likewise with no class or id.

Styling comes entirely from the shared base stylesheets, not from any component-scoped SCSS:

// src/styles/base/_reset.scss (around line 26-32)
body,
ul,
ol,
li,
dl,
dt,
dd,
h1, h2, h3, ... {
  margin: 0;
  padding: 0;
  ...
}

// src/styles/base/_typography.scss (lines 94-121)
p,
ul,
ol {
  + * {
    margin-top: var(--spacing-stacked-margin-large);
  }
}

ul,
ol {
  margin-inline-start: em(20px);

  // remove the top margin when nesting lists
  ul,
  ol {
    margin-top: 0;
    margin-bottom: 0;
  }

  // relieve list styles for lists inside nav el.
  nav & {
    margin: 0;
    list-style: none;
  }
}

li li {
  font-size: 1em;
}

CSS custom properties consumed: --spacing-stacked-margin-large (defined as 0.8em in _typography.scss around line 42, used to add vertical space after a list before the next sibling block) and, indirectly, --colors-text / --color-text for the inherited text color (set at the document root, not by the list rules themselves). List marker glyphs (1., 2., ...) are the browser's native ::marker / list-style: decimal default for <ol> — DocC-Render does not override list-style-type for ordered lists, so numbering, marker style, and the start-attribute offset are all native browser behavior, not CSS-authored or JS-computed.

5. Modern CSS-only alternative

Not applicable

Current behavior: ContentNode.vue's BlockType.orderedList branch (ContentNode.vue#L297-L304) is a one-time, non-reactive mapping from JSON to a native <ol start="...">/<li> tree at render time. There is no client-side state, no toggle, no v-show/v-if, and nothing a reader interacts with afterward that changes the list's appearance or numbering.

Since there is no interactive behavior or hidden/revealed state to replace, none of the stateful modern-CSS mechanisms (<details>/<summary>, radio+:checked, :target, the Popover API, <dialog>, :has()) apply here — there is no state for them to hold. The list itself is already rendered with plain, semantic HTML (<ol>/<li>) and native browser numbering rather than any JavaScript-computed marker text, so there is no legacy JS-rendering technique to migrate away from either.