node

symbol

Wire value: "symbol"

Appears on: Documentation Topic

1. How swift-docc-render consumes this

symbol is one of the two possible values of the top-level kind discriminator on a documentation-reference render node (the other is "article"). Unlike block/inline content kinds — which are dispatched inside ContentNode.vue's renderNode() lookup table — this is a node-tier discriminator, and swift-docc-render does not actually branch on its literal string value anywhere in the Vue layer. There is no if (node.kind === 'symbol') or component-lookup table keyed on "symbol" in the render app.

Instead, both kind: "symbol" and kind: "article" render nodes are routed to the same Vue Router view, src/views/DocumentationTopic.vue, which wraps the shared src/components/DocumentationTopic.vue component. That component's extractProps(json) method destructures the raw RenderNode JSON directly — it never reads json.kind at all. It instead reads discriminating sub-fields from json.metadata (role, symbolKind) and from json.primaryContentSections to decide what to show:

// src/components/DocumentationTopic.vue, extractProps(json)
const {
  ...
  metadata: {
    conformance,
    ...
    role,
    symbolKind = '',
    remoteSource,
    ...
  } = {},
  primaryContentSections,
  relationshipsSections,
  ...
} = json;

See extractProps, lines 619-705. A page produced from a symbol render node typically has metadata.role === "symbol" (or a related role such as containerSymbol, restRequestSymbol, or dictionarySymbol — see the data sheet below), a non-empty metadata.symbolKind (e.g. "property", "class", "func"), and a primaryContentSections array whose first section is usually kind: "declarations". An article-kind node instead has metadata.role === "article", no symbolKind, and no declarations section — the same template conditionally renders (or omits) the Declaration, RequirementMetadata, and other symbol-specific sub-components based on the presence of that data, rather than on kind itself. This is visible in the template guards:

<div v-if="declarations.length" class="declarations-container" ...>
  <Declaration v-for="(declaration, index) in declarations" ... />
</div>
...
<RequirementMetadata v-if="isRequirement" ... />

(lines 75-108). The root template element for the whole page is <div class="doc-topic"> (lines 12-15).

Note: src/constants/TopicTypes.js also defines a string constant symbol: 'symbol', but that is an unrelated, narrower concept — a topic-reference "role" tag used by cross-reference link rendering (e.g. in ContentNode/Reference.vue and Navigator.vue) to decide whether a reference to a symbol should be styled with inline code formatting. It is not the top-level RenderNode kind discriminator documented on this page, and should not be confused with it.

DocCArchive's own transform layer does not yet do anything with this kind: both MyHTMLTransformer.convert(node:) and MyMarkdownTransformer.convert(node:) in Sources/DocCArchive/DocCArchive.swift are still stub placeholders (the former returns a hardcoded <!-- what? --> comment, the latter returns an empty string) regardless of whether node.kind is .symbol or anything else, so a symbol render node parsed via Archive.parseRenderNode(dataPath:) would decode correctly into Components.Schemas.RenderNode but produce no real HTML/Markdown output today.

2. Example JSON and rendered mockup

Real fixture: Tests/DocCArchiveTests/Fixtures/SampleLibrary.doccarchive/data/documentation/samplelibrary/samplestruct/score.json in this repository — a minimal instance-property symbol page (trimmed here to the fields relevant to this page; the full fixture also carries a small references dictionary).

{
  "kind": "symbol",
  "identifier": {
    "interfaceLanguage": "swift",
    "url": "doc://SampleLibrary/documentation/SampleLibrary/SampleStruct/score"
  },
  "metadata": {
    "externalID": "s:13SampleLibrary0A6StructV5scoreSdvp",
    "fragments": [
      { "kind": "keyword", "text": "let" },
      { "kind": "text", "text": " " },
      { "kind": "identifier", "text": "score" },
      { "kind": "text", "text": ": " },
      { "kind": "typeIdentifier", "preciseIdentifier": "s:Sd", "text": "Double" }
    ],
    "modules": [ { "name": "SampleLibrary" } ],
    "role": "symbol",
    "roleHeading": "Instance Property",
    "symbolKind": "property",
    "title": "score"
  },
  "primaryContentSections": [
    {
      "kind": "declarations",
      "declarations": [
        {
          "languages": ["swift"],
          "platforms": ["macOS"],
          "tokens": [
            { "kind": "keyword", "text": "let" },
            { "kind": "text", "text": " " },
            { "kind": "identifier", "text": "score" },
            { "kind": "text", "text": ": " },
            { "kind": "typeIdentifier", "preciseIdentifier": "s:Sd", "text": "Double" }
          ]
        }
      ]
    }
  ],
  "hierarchy": {
    "paths": [
      [
        "doc://SampleLibrary/documentation/SampleLibrary",
        "doc://SampleLibrary/documentation/SampleLibrary/SampleStruct"
      ]
    ]
  },
  "schemaVersion": { "major": 0, "minor": 3, "patch": 0 },
  "sections": [],
  "variants": [
    {
      "paths": ["/documentation/samplelibrary/samplestruct/score"],
      "traits": [ { "interfaceLanguage": "swift" } ]
    }
  ]
}

Instance Property

score
let score: Double

SampleLibrary › SampleStruct › score

3. Data sheet

Authoritative schema object: DocumentationRenderNode in Sources/DocCArchive/Vendored/RenderNode.spec.json (the sibling schema TutorialsPageRenderNode handles the overview/project/article-in-tutorials cases and is out of scope for this page). RenderNode itself is defined as oneOf [TutorialsPageRenderNode, DocumentationRenderNode]. Cross-checked against the generated Components.Schemas.DocumentationRenderNode struct in Sources/DocCArchive/generated/Types.swift (starting at line 5315), which matches the JSON schema field-for-field.

FieldTypeRequiredEnum values / defaultNote
kindstringyes"symbol" | "article"Discriminator for this schema object; this page covers the "symbol" case.
identifierResolvedTopicReferenceyes—Contains interfaceLanguage and the url (a doc:// URL).
schemaVersionSchemaVersionyes—major/minor/patch of the render-JSON schema.
hierarchyDocumentationHierarchyyes—Breadcrumb path(s) from module root to this node.
metadataDocumentationMetadatayes—See sub-table below; carries role, symbolKind, title, etc.
sectionsarray of RenderSectionyes—Generic tutorial-style sections; typically empty for symbol pages (see example).
primaryContentSectionsarray of DocumentationPrimaryRenderSectionno—Declarations, discussion, parameters, etc. First entry is usually kind: "declarations" for a symbol.
referencesmap<string, RenderReference>no—Keyed by doc:// identifier; resolves links/cross-references used elsewhere in the node.
abstractarray of RenderInlineContentno—Summary/abstract line shown under the title.
topicSectionsStylestringnolist | compactGrid | detailedGrid | hidden, default listLayout style for the Topics section.
topicSectionsarray of TasksGroupSectionno—Curated child-topic groups.
seeAlsoSectionsarray of TasksGroupSectionno—"See Also" groups.
defaultImplementationsSectionsarray of TasksGroupSectionno—Protocol default-implementation links.
relationshipsSectionsarray of RelationshipsGroupSectionno—Conforms-to / inherits-from etc.
sampleCodeDownloadSampleDownloadno—Download link for associated sample project.
downloadNotAvailableSummaryarray of RenderBlockContentno—Shown when a sample download is unavailable.
deprecationSummaryarray of RenderBlockContentno—Deprecation notice content.
diffAvailabilityobject (beta/minor/major/sdk → DiffAvailabilityInfo)no—API-diff badges relative to other versions.
variantsarray of RenderNodeVariantno—Per-language/trait path variants for this node.
variantOverridesarray of VariantOverrideno—JSON-Patch overrides applied per trait (e.g. Objective-C variant).

Selected metadata (DocumentationMetadata) fields:

FieldTypeRequiredEnum values / defaultNote
titlestringyes—Page title, e.g. "score".
roleDocumentationRole (string)nosymbol | containerSymbol | restRequestSymbol | dictionarySymbol | pseudoSymbol | pseudoCollection | collection | collectionGroup | article | sampleCode | overview | table | codeListing | link | project | subsection | taskThe practical discriminator swift-docc-render actually branches on (not kind).
symbolKindSymbolKind (plain string, no enum constraint in the schema)noe.g. property, class, func, structDrives roleHeading logic and conditionals like "is this a module page" in DocumentationTopic.vue.
roleHeadingstringno—Human-readable kind label, e.g. "Instance Property".
requiredbooleanno—Marks a protocol-requirement symbol.
externalIDstringno—Compiler/USR-style symbol identifier.
fragmentsarray of DeclarationTokenno—Inline "signature" tokens shown in navigator/links.
modulesarray of DocumentationMetadataModuleno—Owning module name(s).
platformsarray of PlatformAvailabilityno—Per-platform availability/deprecation/beta info.
conformanceConformanceSectionno—"Available when ... conforms to ..." constraint text.

See also: variants & variantOverrides — the full trait-override mechanism behind the two fields in the table above.

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

4. HTML/CSS mapping in DocC-Render output

The whole page renders inside a single root element, <div class="doc-topic">, produced by src/components/DocumentationTopic.vue. Notable descendant hooks used by both symbol and article pages:

All SCSS for this component is co-located in a <style scoped lang="scss"> block inside DocumentationTopic.vue itself (no separate .scss partial) — see roughly lines 796-1008. CSS custom properties consumed/set there include --doc-hero-right-offset, --spacing-stacked-margin-large, --spacing-stacked-margin-xlarge, --declaration-code-listing-margin, --declaration-conditional-constraints-margin, --declaration-source-link-margin, --code-block-style-elements-padding, --aside-border-radius, --code-border-radius, --content-table-title-border-width, and the shared theme tokens --colors-link / --color-link and --colors-grid / --color-grid. Child components (Declaration.vue, PrimaryContent.vue, Topics.vue, Relationships.vue, SeeAlso.vue, DefaultImplementations.vue) each carry their own scoped styles that this page does not enumerate in full.

5. Modern CSS-only alternative

NOT APPLICABLE

The symbol node kind is not itself an interactive widget — it is a data-format discriminator that tells the renderer "build a reference-documentation page, and this page has declarations/availability/symbol metadata." The current JS/Vue behavior in play at this level is plain conditional template rendering: DocumentationTopic.vue uses ordinary Vue v-if directives (v-if="declarations.length", v-if="isRequirement", v-if="primaryContentSectionsSanitized && primaryContentSectionsSanitized.length", etc., lines 75-165) driven by which optional fields are present in the JSON payload. There is no client-side interactive state here (no toggle/tab/expand/collapse behavior gated on kind or role itself) for a CSS mechanism to replace — the one truly stateful, click-driven widget on the page, the "Show/Hide other declarations" toggle (toggleDeclList/declListExpanded, lines 706-708 and 118-128), belongs to the declarations primary-content-section kind, not to the symbol node kind itself, and should be assessed on that section's own reference page rather than here. At the node-kind level, the right characterization is simply: pick-one-of-two-templates-at-build-time based on a string field, which is inherently a server/build-time concern, not something a browser-side CSS selector could hold state for.