section

relationships

Wire value: "relationships"

Appears on: Documentation Topic

1. How swift-docc-render consumes this

relationships is a symbol-page section kind: a RelationshipsGroupSection (wire schema name) / RelationshipsRenderSection (swift-docc Swift type name) is one entry in the top-level RenderNode's relationshipsSections array. Unlike the block/inline content kinds dispatched through ContentNode.vue's renderNode() lookup table, this is a section-tier kind: it is not looked up by a string-keyed dispatch table at all. relationshipsSections is passed straight through as a typed prop from DocumentationTopic.vue to a single fixed child component:

<Relationships
  v-if="relationshipsSections"
  :sections="relationshipsSections"
  :enableMinimized="enableMinimized"
/>

That child is DocumentationTopic/Relationships.vue. Its template wraps a shared ContentTable (the same collapsible-heading wrapper used by Topics/Default Implementations/See Also) around one ContentTableSection per relationship group, using the group's title (e.g. "Conforms To") as the sub-heading:

<ContentTable :anchor="contentSectionData.anchor" :title="$t(contentSectionData.title)" :enableMinimized="enableMinimized">
  <Section v-for="section in sectionsWithSymbols" :key="section.type" :title="section.title" :anchor="section.anchor">
    <List :symbols="section.symbols" :type="section.type" />
  </Section>
</ContentTable>

The component's own sectionsWithSymbols computed property is the only real logic here: for each incoming group it resolves every entry in identifiers against the page-wide references map (via the referencesProvider mixin), dropping any identifier that fails to resolve, and hands the resulting resolved-symbol array to List — aliased to RelationshipsList.vue. RelationshipsList renders a ul.relationships-list of li.relationships-item, each showing either a Reference link (if the resolved symbol has a url) or plain code text (via WordBreak) for unresolvable symbols, optionally followed by a ConditionalConstraints node when the resolved reference carries generic-constraint information (e.g. "Available when Element conforms to ..."). The component also injects the app store to compute API-diff highlighting (changeType, changed-* classes) against state.apiChanges, and switches between an inline comma-separated layout (.inline, used when there are 3 or fewer symbols and none carry constraint info) and a one-per-line layout (.column) otherwise.

The section's anchor/heading text come from a shared constants file, not from the payload itself: constants/ContentSectionAnchors.js defines MainContentSectionAnchors.relationships = { title: 'sections.relationships', anchor: 'relationships', level: 2 }, which is also what registers the on-this-page nav entry (see mixins/onThisPageRegistrator.js, lines 101–102).

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

See also: Localization fallback — how $t()/locale-key lookup works across every kind that uses it.

2. Example JSON and rendered mockup

Fixture source: Tests/DocCArchiveTests/Fixtures/SampleLibrary.doccarchive/data/documentation/samplelibrary/sampleerror.json (a real DocC-generated RenderNode in this repository's own test fixtures) — its relationshipsSections array, together with the matching entries pulled from that same file's top-level references map so the mockup below is faithful to what swift-docc-render would actually resolve.

{
  "relationshipsSections": [
    {
      "kind": "relationships",
      "title": "Conforms To",
      "type": "conformsTo",
      "identifiers": [
        "doc://SampleLibrary/s5ErrorP",
        "doc://SampleLibrary/s8SendableP",
        "doc://SampleLibrary/s16SendableMetatypeP"
      ]
    }
  ],
  "references": {
    "doc://SampleLibrary/s5ErrorP": {
      "identifier": "doc://SampleLibrary/s5ErrorP",
      "title": "Swift.Error",
      "type": "unresolvable"
    },
    "doc://SampleLibrary/s8SendableP": {
      "identifier": "doc://SampleLibrary/s8SendableP",
      "title": "Swift.Sendable",
      "type": "unresolvable"
    },
    "doc://SampleLibrary/s16SendableMetatypeP": {
      "identifier": "doc://SampleLibrary/s16SendableMetatypeP",
      "title": "Swift.SendableMetatype",
      "type": "unresolvable"
    }
  }
}

Note: all three referenced symbols in this fixture are external standard-library protocols with "type": "unresolvable" (no url), so Relationships.vue's sectionsWithSymbols computed property still includes them (a reference object exists, it is just not a navigable link) and RelationshipsList.vue falls back to its WordBreak-wrapped code branch rather than a clickable Reference for each. With exactly 3 symbols and no conformance constraint data, this list also qualifies for the .inline (comma-separated) layout per shouldDisplayInline.

Relationships
Conforms To
  • Swift.Error, 
  • Swift.Sendable, 
  • Swift.SendableMetatype

mockup: a "Relationships" content-table heading, a "Conforms To" sub-heading, and an inline comma-separated list of the three (unresolvable, so plain-code rather than linked) conformed protocols — approximating .relationships-list.inline.

3. Data sheet

Source: Sources/DocCArchive/Vendored/RenderNode.spec.json, schema object #/components/schemas/RelationshipsGroupSection (also referenced by DocumentationRenderNode/relationshipsSections, an array of this schema), cross-checked against the generated Components.Schemas.RelationshipsGroupSection struct in Sources/DocCArchive/generated/Types.swift (lines 6348–6393).

FieldTypeRequiredEnum values / defaultNote
kind string yes "relationships" (single-case enum) Generated as a one-case KindPayload enum. Matches the hardcoded let kind: RenderSectionKind = .relationships in swift-docc's Swift model.
title string yes — Human-readable group heading, e.g. "Conforms To", "Inherits From", "Inherited By", "Conforming Types". Used verbatim as the ContentTableSection sub-heading text.
type (Swift property _type, JSON key type) string yes "conformsTo", "conformingTypes", "inheritsFrom", "inheritedBy" Machine-readable relationship kind. swift-docc-render uses this as the Vue :key for the v-for loop and to look up API-diff change data via RelationshipChangeMapping (only conformsTo/inheritsFrom/inheritedBy are mapped there — conformingTypes is not, so diff highlighting for that relationship type is not wired up in RelationshipsList.vue).
identifiers array of string (format: reference) yes — Each string is a doc:// reference identifier resolved against the page's top-level references map. swift-docc's decoder additionally calls decoder.registerReferences(identifiers) during decode (see RelationshipsRenderSection.init(from:)) to make sure referenced symbols get pulled into the render context. Identifiers that fail to resolve against references are silently dropped by Relationships.vue's sectionsWithSymbols, not shown as broken links.

Note on the Swift struct site: no swiftStructSite was pre-supplied for this page, so Sources/SwiftDocC/Model/Rendering/ was searched directly. The matching Swift model is RelationshipsRenderSection.swift, which matches the wire schema field-for-field (kind, title, identifiers, type) with no undocumented extra properties — unlike some other section kinds, there is no gap between the vendored JSON Schema and swift-docc's actual Swift type here.

4. HTML/CSS mapping in DocC-Render output

Rendered DOM shape, composed from three templates:

SCSS: ContentTable.vue's own scoped block (importing docc-render/styles/_core.scss) drives the outer container spacing and heading style; ContentTableSection.vue's scoped block drives the per-group heading/content padding (with a distinct small-breakpoint layout under @include breakpoint(small)); and RelationshipsList.vue's own scoped block (lines 127–177) defines .relationships-list's .column/.inline/.changed variants, including the comma-separator trick (li:not(:last-child)::after { content: ",\00a0" }) used for the inline layout.

Key CSS custom properties consumed:

DocCArchive transform status: MyHTMLTransformer and MyMarkdownTransformer (Sources/DocCArchive/DocCArchive.swift) are still stub placeholders — the HTML transformer returns a hardcoded comment and the Markdown transformer returns an empty string, so there is no kind-specific handling of relationshipsSections/RelationshipsGroupSection in DocCArchive today.

5. Modern CSS-only alternative

NOT APPLICABLE

Current behavior: everything under Relationships.vue and RelationshipsList.vue is one-way, stateless prop-to-template rendering. The only non-trivial logic is derived, read-only computed state — sectionsWithSymbols resolves reference identifiers against a passed-in map, changeType/classes derive CSS classes from a diff-changes lookup, and shouldDisplayInline picks between two static layouts based on the item count and whether any item has constraint data. None of this is runtime user-driven interactivity (no click handlers, no toggled visibility, no open/closed state); it is all resolved once when the component's props/injected store are set, exactly like a server-side template would behave. There is consequently no client-side state-holding mechanism (no v-show/v-if toggle, no modal, no tab switch) for a native CSS mechanism such as <details>, a :checked radio hack, or <dialog> to replace. The verdict is not applicable because this kind has no interactive behavior to begin with — it is a fixed conditional list layout (inline-vs-column, chosen once from static input data) rendered by ordinary CSS class selectors, not a state machine.