1. How swift-docc-render consumes this
There is no Vue component, and no line of code anywhere under
swift-docc-render/src/, that tests a reference's type for the literal string
"externalLocation" — a full grep of src/components/ and src/views/
for that string returns nothing. externalLocation is not a distinct rendering path; it is
an alternate wire-format value for the same reference object swift-docc-render already
handles as a download reference (see section 3 for why the schema groups them together).
Wherever that shared object is consumed, only its url and identifier fields
are read — the type discriminator itself is never branched on downstream of the Swift
decode step.
The one call site that actually renders one of these download-family references is the "sample code download" button on a documentation page:
-
components/DocumentationTopic.vue#L64-L70— if the RenderNode has a top-levelsampleCodeDownloadobject, it renders<DownloadButton :action="sampleCodeDownload.action" linksToAsset />, whereDownloadButtonis a local alias forCallToActionButton(DocumentationTopic.vue#L251).sampleCodeDownload.actionis areference-type action object holding anidentifierstring — not the reference payload itself. -
components/CallToActionButton.vue#L11-L21— wraps the action in<DestinationDataProvider :destination="action" v-slot="{ url, title }">and passes the resolvedurl/titlestraight into<ButtonLink :url="normalizeUrl(url)" ... >{{ title }}</ButtonLink>. -
components/DestinationDataProvider.vue#L61-L76— this is the actual lookup:reference: ({ references, destination }) => (references[destination.identifier] || {})resolves the identifier against the RenderNode's top-levelreferencesmap. Sincedestination.type === 'reference',linkUrlresolves toreference.urlandlinkTitletodestination.overridingTitle || reference.title. No branch here inspects whetherreference.typeis"download"or"externalLocation"— both shapes carry aurlfield and neither carries atitlefield, solinkTitlefalls back entirely to the caller-suppliedoverridingTitle(populated server-side from the authored@CallToActionbutton label; see section 3). -
Note the one place
typeis read on this component,DestinationDataProvider.vue#L49-L54'sisExternalcomputed — it only matches the unrelatedlinkdestination/reference type (for the deprecated inline-URL call-to-action form), so anexternalLocation(ordownload) reference is never treated as "external" for the purposes of appending"(opens in browser)"to the button's aria-label, even though the URL it points at is, in theexternalLocationcase, off-site by definition.
CallToActionButton.vue#L36-L39's
normalizeUrl only rewrites relative paths through the asset-normalization helpers when
linksToAsset is set and the URL is not already absolute
(isAbsoluteUrl); an externalLocation's URL is normally already an absolute
https://… URL (see section 3), so in practice this early-returns the URL unchanged. The
resulting <ButtonLink> then swaps in a Reference (plain anchor)
component whenever a url is present
(ButtonLink.vue#L44-L47).
See also: The references map — how this and every other reference-dictionary lookup works across kinds.
2. Example JSON and rendered mockup
A real fixture exists in swift-docc's own test suite:
Tests/SwiftDocCTests/Rendering/Rendering Fixtures/external-location-custom-url.json
(pinned commit 8b8d8268aa). The relevant references entry and the
sampleCodeDownload block that points at it are reproduced verbatim below (trimmed to the
fields relevant to this page):
{
"references": {
"doc://org.swift.docc.example/downloads/sample.zip": {
"identifier": "ExternalLocation.zip",
"url": "https://example.com/ExternalLocation.zip",
"type": "externalLocation"
}
},
"sampleCodeDownload": {
"action": {
"identifier": "doc://org.swift.docc.example/downloads/sample.zip",
"isActive": true,
"overridingTitle": "Download",
"type": "reference"
}
}
}
(Fixture provenance: real file, not synthesized — see path above.)
3. Data sheet
Schema object: #/components/schemas/DownloadRenderReference,
Sources/DocCArchive/Vendored/RenderNode.spec.json:1882-1904. This is a single object
schema shared by two wire values — "download" and "externalLocation" are
both listed in the type property's enum — rather than
externalLocation having its own schema object. In the generated Swift, OpenAPI Generator's
deduplication produced three related-but-distinct structs from this schema as it recurs at different
points in the merged spec: Components.Schemas.DownloadRenderReference
(Types.swift:619-657, type enum restricted to only .download,
checksum non-optional — this is the copy used by the tutorials-overview
CallToActionSection shape) and
Components.Schemas.DownloadRenderReference1 (a second, differently-scoped duplicate,
also .download-only). The one that actually carries externalLocation as a
valid case is Components.Schemas.DownloadRenderReference2
(Types.swift:5132-5171), whose nested _TypePayload enum has both
case download = "download" and case externalLocation = "externalLocation"
(Types.swift:5135-5138) and whose checksum field is optional
(Swift.String?) — matching the spec, where checksum is listed under
properties but not under required. This struct is one arm of the generated
RenderReference1 discriminated union (Types.swift:4802-4821, case
.DownloadRenderReference2 at line 4817), which is the element type of the RenderNode's
top-level references dictionary ([String: Components.Schemas.RenderReference1],
e.g. Types.swift:2963 / 5332). Decoding tries each arm's initializer in
declared order and keeps the first that succeeds (Types.swift:4822-4878), so a JSON object
with "type": "externalLocation" is accepted here (case 7,
DownloadRenderReference2) even though the earlier-tried arms
(ImageRenderReference, VideoRenderReference2, FileRenderReference,
FileTypeRenderReference, XcodeRequirementRenderReference,
TopicRenderReference1) do not have a type enum case matching that string, so
their decode attempts throw and are skipped.
| Field | Type | Required? | Enum values / default | Note |
|---|---|---|---|---|
type | string | yes | "download" | "externalLocation" | Discriminator. Both values decode to the same Swift model on the swift-docc authoring side (DownloadReference, see below) and to the same generated struct (DownloadRenderReference2) on the DocCArchive/OpenAPI side. |
identifier | string | yes | — | Key used to look this object up from the RenderNode's top-level references dictionary (e.g. the sampleCodeDownload.action.identifier value points here). |
url | string | yes | — | The downloadable resource's location. For externalLocation this is expected to be an absolute, off-site URL written verbatim by the author; swift-docc-render does not distinguish it from a same-site download URL at render time (section 1). |
checksum | string | no | — | SHA-512 hex digest of the resource, when known. Not read anywhere in the swift-docc-render call path found in section 1 (no integrity check is surfaced in the UI). |
Swift-side model (authoring/encoding, secondary to the schema above per the priority order for this
page): swift-docc's RenderReferenceType enum
(Sources/SwiftDocC/Model/Rendering/References/RenderReference.swift:29) declares
case … download, link, externalLocation as sibling raw-string cases of one enum, and both
decode through the same DownloadReference struct
(Sources/SwiftDocC/Model/Rendering/Tutorial/References/DownloadReference.swift:14-94):
its decoding initializer (DownloadReference.swift:72-79) accepts whatever string is in the
JSON's type field into its own type property without validating it against
the enum's cases, and the shared reference-container decoder
(Sources/SwiftDocC/Model/Rendering/RenderNode/CodableRenderReference.swift:40-41) routes
both .download and .externalLocation to
DownloadReference.init(from:). Searching swift-docc's current sources for anywhere that
constructs a reference with type: .externalLocation (as opposed to accepting it on
decode) turns up nothing — DownloadReference's type property defaults to
.download (DownloadReference.swift:23), and the one production call site that
builds a verbatim-URL download reference for an authored external link
(Sources/SwiftDocC/Model/Rendering/RenderNodeTranslator.swift:846-855, backing the
@CallToAction(url:) directive) uses the default .download type, not
.externalLocation. As far as this codebase search can tell, externalLocation
is a decode-accepted wire value for interoperability with render JSON produced by another encoder (or
an earlier revision of swift-docc's own encoder) rather than a value swift-docc's current encoder emits
itself — the external-location-custom-url.json fixture in section 2 is a hand-authored
test input exercising the decode path, not a captured real-world encoder output.
AssetReferences.swift:16 confirms the two are still meant to be treated identically as
"asset" references app-wide: let assetTypes = [RenderReferenceType.image, .video, .file,
.download, .externalLocation].
4. HTML/CSS mapping in DocC-Render output
There is no dedicated markup "for an externalLocation reference" — as established above,
the object is pure data consumed generically as a URL + title pair, and the only DOM it produces is
whatever the calling button component renders. For the one call site found (the sample-code download
button):
<div>wrapper with no class, gated byv-if="sampleCodeDownload", insideDocumentationTopic.vue's hero (DocumentationTopic.vue:64-70).<a class="button-cta">(plus modifier classis-darkwhen applicable) — the root element rendered byButtonLink.vueonce aurlis resolved, additionally carrying the caller'sclass="sample-download"(ButtonLink.vue:12-19; the anchor itself comes from theReferencecomponent swapped in viaresolvedComponent).
Styling: DocumentationTopic.vue's scoped SCSS contributes only layout spacing for the
wrapper (.sample-download { margin-top: 20px; },
DocumentationTopic.vue:944-946). The button's own look comes from
ButtonLink.vue's scoped <style scoped lang="scss"> block
(ButtonLink.vue:51-99, importing docc-render/styles/_core.scss), which
consumes the CSS custom properties --colors-button-light-background /
--color-button-background, --color-button-border,
--button-border-radius, --button-border-style,
--button-border-width, --colors-button-text / --color-button-text,
--colors-button-light-backgroundActive / --color-button-background-active, and
--colors-button-light-backgroundHover / --color-button-background-hover (plus
dark-mode variants --colors-button-dark-background,
--colors-button-dark-backgroundActive, --colors-button-dark-backgroundHover
under the .is-dark modifier). None of this styling varies based on whether the underlying
reference's type was "download" or "externalLocation" — the CSS
has no hook into that field at all.
5. Modern CSS-only alternative
Not applicable
Current behavior in play: none of the JS touched in this page's render path holds any client-side UI
state tied to this kind. DestinationDataProvider.vue is a stateless computed-properties
lookup (object property access against the RenderNode's static references map, resolved
once per render), CallToActionButton.vue and ButtonLink.vue are stateless
presentational wrappers around a plain <a href="…">, and the resulting anchor has no
open/closed, selected/unselected, or tabbed state to hold — clicking it simply navigates or downloads,
which the browser already does natively for a plain link. There is consequently no toggle, disclosure,
tab set, or modal behavior anywhere in this kind's consumption for a mechanism like
<details>/<summary>, a :checked-driven radio group, :target,
the Popover API, or <dialog> to replace. The only thing worth flagging as a
CSS-relevant nuance is the "(opens in browser)" aria-label suffix
(DestinationDataProvider.vue:60,85-87) that swift-docc-render's IDE mode appends
for link-type destinations — this is accessibility text generated in JS from a boolean
computed property, not a CSS state, and as noted in section 1 it does not even apply to
externalLocation references today.