block

termList

Wire value: "termList"

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

1. How swift-docc-render consumes this

The dispatch table for block/inline content kinds lives in src/components/ContentNode.vue, in the module-level renderNode() factory function (defined at line 121). That function returns a closure with a switch (node.type) statement (line 260) which is mapped over every item in a ContentNode's content array. The literal wire value "termList" is registered in the shared BlockType constant map used throughout the file:

export const BlockType = {
  ...
  table: 'table',
  termList: 'termList',
  unorderedList: 'unorderedList',
  ...
};

ContentNode.vue lines 37–54

The actual render case is a single, compact branch with no delegated child component — unlike table (which delegates to a Table.vue component) or tabNavigator (which delegates to TabNavigator.vue), termList is rendered directly as a native HTML description list:

case BlockType.termList:
  return createElement('dl', {}, node.items.map(({ term, definition }) => [
    createElement('dt', {}, (
      renderChildren(term.inlineContent)
    )),
    createElement('dd', {}, (
      renderChildren(definition.content)
    )),
  ]));

ContentNode.vue lines 345–353

Each item in node.items becomes one <dt>/<dd> pair inside a single <dl> that wraps the whole term list. The term's inlineContent (an array of RenderInlineContent, e.g. plain text, emphasis, strong, or a cross-reference) is rendered recursively via the same renderChildren helper used elsewhere in this file and placed inside <dt>. The definition's content (an array of full RenderBlockContent — so a definition can itself contain paragraphs, images, tables, code listings, etc.) is rendered into <dd>.

ContentNode.vue also exposes tree-walking utilities (map, forEach) used elsewhere in docc-render (for example, to build search/plaintext indexes or to transform a content tree). Both utilities have explicit BlockType.termList cases that recurse into both item.term.inlineContent and item.definition.content for every item, confirming that a term list item is treated as a genuine two-part container rather than a single opaque leaf:

case BlockType.termList:
  return fn({
    ...node,
    items: node.items.map(item => ({
      ...item,
      term: { inlineContent: $map(item.term.inlineContent) },
      definition: { content: $map(item.definition.content) },
    })),
  });

map(): lines 592–600 · forEach(): lines 641–646

No dedicated Vue component exists for term lists (no TermList.vue under src/components/ContentNode/); the entire behavior is the inline createElement('dl', ...) call shown above. The thin wrapper components src/components/DocumentationTopic/ContentNode.vue and src/components/Article/ContentNode.vue simply re-export the base ContentNode.vue's props/methods and do not add any termList-specific behavior.

2. Example JSON and rendered mockup

The example below is trimmed (to two term/definition pairs) from a real swift-docc test fixture, Tests/SwiftDocCTests/Rendering/Rendering Fixtures/term-lists-1.json, which exercises a termList block inside a symbol page's discussion content.

{
  "type": "termList",
  "items": [
    {
      "term": {
        "inlineContent": [
          { "type": "text", "text": "First term" }
        ]
      },
      "definition": {
        "content": [
          {
            "type": "paragraph",
            "inlineContent": [
              { "type": "text", "text": "A paragraph that spans multiple lines." }
            ]
          }
        ]
      }
    },
    {
      "term": {
        "inlineContent": [
          { "type": "text", "text": "Another term" }
        ]
      },
      "definition": {
        "content": [
          {
            "type": "paragraph",
            "inlineContent": [
              { "type": "text", "text": "Second definition." }
            ]
          },
          {
            "type": "paragraph",
            "inlineContent": [
              { "type": "text", "text": "It has " },
              {
                "type": "emphasis",
                "inlineContent": [
                  { "type": "text", "text": "multiple" }
                ]
              },
              { "type": "text", "text": " paragraphs." }
            ]
          }
        ]
      }
    }
  ]
}
First term

A paragraph that spans multiple lines.

Another term

Second definition.

It has multiple paragraphs.

3. Data sheet

Schema source: Sources/DocCArchive/Vendored/RenderNode.spec.json, objects TermList (line 941) and TermListItem (line 962), one of the discriminated members of the RenderBlockContent union (referenced at line 480). Generated Swift types: Sources/DocCArchive/generated/Types.swift, Components.Schemas.TermList (struct at line 4440) and Components.Schemas.TermListItem (struct at line 4467).

FieldTypeRequiredEnum / defaultNote
typestringyesenum: "termList" (single value)Discriminator for the RenderBlockContent union; generated as Components.Schemas.TermList._TypePayload, a single-case String enum.
itemsarray of TermListItemyes—One entry per term/definition pair; order is preserved and rendered as sequential <dt>/<dd> pairs.
TermListItem.termobject { inlineContent }yes—Required sub-object; wraps the term's inline content.
TermListItem.term.inlineContentarray of RenderInlineContentyes—The formatted term text (may contain text, emphasis, strong, reference, etc.); rendered inside <dt>.
TermListItem.definitionobject { content }yes—Required sub-object; wraps the definition's block content.
TermListItem.definition.contentarray of RenderBlockContentyes—Full block content (paragraphs, lists, images, tables, etc.), not just inline text; rendered inside <dd>.

Note on Swift-side naming: the OpenAPI generator maps the JSON field type to a Swift property named _type (with CodingKeys mapping it back to "type" on the wire) because type collides with generator-reserved naming; this is purely a Swift ergonomics detail and does not change the wire format.

DocCArchive transform status: as of this writing, MyHTMLTransformer and MyMarkdownTransformer in Sources/DocCArchive/DocCArchive.swift are both stub placeholders operating on the whole RenderNode (returning a hardcoded HTML comment and an empty string, respectively) with no per-block-kind switch at all, so a Components.Schemas.TermList value parsed by DocCArchive does not yet flow through any real HTML or Markdown conversion logic.

4. HTML/CSS mapping in DocC-Render output

Rendered structure: a single <dl> element (no id or class attribute is applied by the termList case itself), containing alternating <dt> (term) and <dd> (definition) elements — one pair per items entry. The whole tree of block content (including any termList nodes) is wrapped by the parent ContentNode component in a <div class="content"> (see ContentNode.vue lines 529–535).

No dedicated SCSS file targets dl/dt/dd specifically. The only rule touching these elements is the global reset in src/styles/base/_reset.scss, which zeroes their margin and padding alongside body, ul, ol, li, headings, and other block elements:

body,
ul,
ol,
li,
dl,
dt,
dd,
h1, h2, h3, h4, h5, h6,
...
{
  margin: 0;
  padding: 0;
}

_reset.scss lines 26–51

Notably, src/styles/base/_typography.scss defines an inter-block spacing rule that adds top margin to any element that immediately follows a paragraph or list (p, ul, ol { + * { margin-top: var(--spacing-stacked-margin-large); } }, lines 93–100 of that file) — but dl is not included as either the trigger selector or explicitly targeted as the following sibling. In practice this means a termList block does not automatically receive the same --spacing-stacked-margin-large top-margin treatment other DocC block kinds get when they follow a paragraph or list; because the reset above already zeroes dl's own margin, an author-adjacent termList can end up flush against the preceding block unless some other layout rule (not found in this search) supplies spacing. Beyond the reset, term list content inherits ordinary body typography (color via var(--colors-text, var(--color-text)), font via var(--typography-html-font, ...), both set on body/html in _typography.scss) and whatever CodeVoice/Reference/emphasis styling applies to inline content nested inside the <dt>/<dd>.

5. Modern CSS-only alternative

Not applicable

The current implementation is entirely stateless: renderNode()'s BlockType.termList branch is a pure, one-shot mapping from JSON (node.items) to a static <dl>/<dt>/<dd> tree at render time (ContentNode.vue lines 345–353). There is no client-side interaction state to replace — no toggle, no visibility switch, no tab selection, and no JS event handler attached to the term list itself. It is a plain semantic HTML list, already using the native <dl> description-list element rather than a JS-driven substitute, so there is no click-handler/`v-show`/component-`data` state machine for a CSS-only mechanism (such as :checked + sibling selectors, :target, or <details>) to take over. The one legitimate "modern CSS" question for this kind is purely about the missing inter-block spacing noted in section 4 (the p, ul, ol { + * {...} } rule not covering dl), but that is a static layout/spacing gap, not an interactive-state gap, so it does not motivate any of the state-holding CSS mechanisms this section is scoped to evaluate.