1. Directory layout
A DocC archive is a plain directory tree, not an opaque bundle format — every file in it is
either a static web asset (HTML/CSS/JS for the bundled single-page viewer) or one of a small,
fixed set of top-level JSON files. Six of those JSON files are what DocCArchive's
Archive type (Sources/DocCArchive/DocCArchive.swift) parses today, plus
one JSON file and two binary files that exist in every archive but that this library does
not yet parse. This is the real top level of
Tests/DocCArchiveTests/Fixtures/ExampleDocs.doccarchive, annotated:
ExampleDocs.doccarchive
├── metadata.json always present — see §2
├── diagnostics.json always present, deprecated (removed after Swift 6.3) — see §4
├── indexing-records.json only with `docc convert --emit-digest` — see §5
├── linkable-entities.json only with `--enable-experimental-external-link-support` — see §6
├── assets.json always present — NOT parsed by DocCArchive today
├── index/
│ ├── index.json always present — see §3
│ ├── data.mdb NOT parsed by DocCArchive today (LMDB navigator database)
│ ├── navigator.index NOT parsed by DocCArchive today (binary)
│ └── availability.index NOT parsed by DocCArchive today (binary)
├── data/
│ └── documentation/…json one RenderNode per symbol/article — see §7
├── documentation/… static HTML pages (bundled single-page viewer, one per route)
├── css/, js/, img/, favicon.* static web assets for the bundled viewer
└── index.html entry point for the bundled viewer
assets.json lists the images/videos/downloads referenced anywhere in the archive
(each an empty array in this fixture, since ExampleDocs has none); the two
index/*.index files and index/data.mdb back the bundled viewer's
client-side search and navigator sidebar. All three are real, always-present archive contents —
they're just outside this library's and this reference site's current scope, since nothing in
DocCArchive.swift decodes them (confirmed: no parseAssets() or
LMDB/index-file reader exists in the source). SampleLibrary.doccarchive, the other
test fixture, has the identical six-JSON-file shape at its top level, just with many more
per-symbol files under data/documentation/.
2. metadata.json → Metadata
Parsed by Archive.parseMetadata()
(DocCArchive.swift, line 45), which reads {baseArchivePath}/metadata.json
and decodes it as Components.Schemas.Metadata. Schema source:
Sources/DocCArchive/Vendored/Metadata.json, object Metadata (three
required fields: bundleDisplayName, bundleID,
schemaVersion); generated as Components.Schemas.Metadata in
Sources/DocCArchive/generated/Types.swift (line 2805). The schema traces to
swift-docc's BuildMetadata type
(Sources/SwiftDocC/Model/BuildMetadata.swift, line 14).
Real fixture, ExampleDocs.doccarchive/metadata.json in full (it's this short):
{
"bundleDisplayName" : "ExampleDocs",
"bundleID" : "ExampleDocs",
"schemaVersion" : {
"major" : 0,
"minor" : 1,
"patch" : 0
}
}
bundleDisplayName/bundleID identify which documentation bundle (module,
roughly) produced the archive — relevant once an archive contains more than one bundle's worth of
content, per includedArchiveIdentifiers in §3. schemaVersion is the
render-schema version this specific archive was written against; it's a separate, independently
versioned number from the vendored spec's schemaVersion tracked in
Sources/DocCArchive/VendorVersion.swift and referenced throughout the Kind Catalog —
don't conflate the two when comparing versions.
3. index/index.json → RenderIndex
Parsed by Archive.parseIndex() (DocCArchive.swift, line 79 — commented
"always available for the static hosting scenarios, which is default"), which reads
{baseArchivePath}/index/index.json and decodes it as
Components.Schemas.RenderIndex. This is the archive's manifest: a recursive tree of
every documentation page it contains, independent of and much smaller than any individual
RenderNode.
Schema source: Sources/DocCArchive/Vendored/RenderIndex.spec.json. The top-level
RenderIndex object (line 11) has two required fields —
schemaVersion and interfaceLanguages (a map of language name, e.g.
"swift", to an array of Node) — plus two optional fields,
references (a map of image references, for icons attached to index nodes) and
includedArchiveIdentifiers (the list of bundle identifiers folded into this archive,
matching §2's bundleID when there's exactly one). Generated as
Components.Schemas.RenderIndex in Types.swift (line 30); traces to
swift-docc's RenderIndex.swift#L24.
The recursive Node type (spec line 45; generated as
Components.Schemas.Node in Types.swift, line 105; traces to
RenderIndex.swift#L117)
has one required field, title, and several optional ones: type (a
34-value enum covering everything from "module"/"struct"/"class"
to "article"/"tutorial"-adjacent kinds), path (present only
when this node has a corresponding RenderNode file — see §7), deprecated/
external/beta flags, an icon image reference, and
children — an array of more Nodes, making the whole thing a tree, not a
flat list.
Real fixture, ExampleDocs.doccarchive/index/index.json in full:
{
"includedArchiveIdentifiers" : [ "ExampleDocs" ],
"interfaceLanguages" : {
"swift" : [
{
"title" : "ExampleDocs",
"type" : "module",
"path" : "/documentation/exampledocs",
"children" : [
{
"title" : "ExampleArticle",
"type" : "article",
"path" : "/documentation/exampledocs/examplearticle"
}
]
}
]
},
"schemaVersion" : { "major" : 0, "minor" : 1, "patch" : 2 }
}
The canonical way to walk this tree is Archive.walkRenderIndexNodes(nodes:doing:)
(DocCArchive.swift, lines 104–110), which depth-first-visits every node via the
single-node overload walkRenderIndexNodes(node:level:doing:) (lines 112–121),
recursing into node.children when present. Archive.convert(transformer:)
(lines 143–191) shows the real usage pattern end to end: parse the index, pull
index.interfaceLanguages.additionalProperties["swift"] (the "additionalProperties"
name is an OpenAPI-generator artifact of representing a [String: [Node]] map — see the
inline comment at lines 158–167 for why), walk it, and for every visited node that has a
path, call parseRenderNode(dataPath:) (§7) to load that node's actual
content. Nodes without a path — e.g. pure grouping nodes — are skipped, not treated as
errors.
4. diagnostics.json
Parsed by Archive.parseDiagnostics() (DocCArchive.swift, line 56) as
Components.Schemas.Diagnostics, a bare array of DiagnosticSummary
objects. Schema source: Sources/DocCArchive/Vendored/Diagnostics.json, whose own
info.description states it plainly: "Specification of the deprecated DocC
diagnostics.json digest file. This deprecated file will be removed after 6.3 is
released." Generated as Components.Schemas.Diagnostics, a typealias for
[Components.Schemas.DiagnosticSummary], in Types.swift (line 790).
Each DiagnosticSummary carries a severity (integer), summary
and optional explanation strings, an optional start
Location (line/column) and source file path, and an array of
Notes (each its own location + message) — the same shape
Swift compiler diagnostics use, unsurprisingly, since this captures the warnings/errors DocC itself
emitted while building the archive, not anything about the documented symbols. The
ExampleDocs fixture's file is simply [] — a clean build produced no
diagnostics to report.
5. indexing-records.json
Parsed by Archive.parseIndexingRecords() (DocCArchive.swift, line 68 —
commented "only available when the docc archive was created with --emit-digest") as
Components.Schemas.IndexingRecords, a typealias for
[Components.Schemas.IndexingRecord] (Types.swift, line 885). This is a
full-text search index: one IndexingRecord per indexable page/section, each with
kind (overview/tutorial/article/
tutorialSection/symbol), a resolved location (either
topLevelPage or contained-in-page), title,
summary, the page's headings array, and
rawIndexableTextContent — the flattened plain-text body used for search matching.
Schema source: Sources/DocCArchive/Vendored/IndexingRecords.spec.json; traces to
IndexingRecord.swift#L14.
Real fixture excerpt, one record from ExampleDocs.doccarchive/indexing-records.json:
{
"headings" : [ "Overview", "Section header" ],
"kind" : "article",
"location" : {
"type" : "topLevelPage",
"reference" : {
"interfaceLanguage" : "swift",
"url" : "doc://ExampleDocs/documentation/ExampleDocs/ExampleArticle"
}
},
"rawIndexableTextContent" : "An example article to display. Overview Description of what the article is about…",
"summary" : "An example article to display.",
"title" : "ExampleArticle"
}
This file exists only to power full-text search over a statically-hosted archive without a server
— it's a derived, denormalized index of content that also lives in the RenderNode
files under data/ (§7); nothing here is unique source-of-truth data.
6. linkable-entities.json
Parsed by Archive.parseLinkableEntities() (DocCArchive.swift, line 127)
as Components.Schemas.LinkableEntities, a typealias for
[Components.Schemas.LinkDestinationSummary] (Types.swift, line 1133).
The function's doc comment (lines 123–126) describes it precisely: "only available when the
archive was generated with the experimental linkable entities enabled. This holds — or could hold —
almost everything from the --emit-digest output and quite a bit more, enabling easier
references to content external to the DocC archive." (Generated with
docc convert --enable-experimental-external-link-support, per
Sources/DocCArchive/Documentation.docc/UnderstandingDocCArchiveStructure.md.) Schema
source: Sources/DocCArchive/Vendored/LinkableEntities.json; traces to
LinkDestinationSummary.swift#L76.
Each LinkDestinationSummary is self-contained enough to resolve a cross-archive link
without opening the target archive's own RenderNode file: it carries the symbol's
usr (mangled name), a doc://MODULE/… referenceURL, its
title/abstract/kind, optional declaration
fragments, and — notably — its own nested references map and
variants array, the same two cross-cutting mechanisms that show up throughout the
per-page RenderNode schema. Real fixture, one record from
ExampleDocs.doccarchive/linkable-entities.json:
{
"abstract" : [ { "text" : "An example article to display.", "type" : "text" } ],
"availableLanguages" : [ "swift" ],
"kind" : "org.swift.docc.kind.article",
"language" : "swift",
"path" : "/documentation/exampledocs/examplearticle",
"referenceURL" : "doc://ExampleDocs/documentation/ExampleDocs/ExampleArticle",
"taskGroups" : [ ],
"title" : "ExampleArticle"
}7. From an index Node to a RenderNode
Every index Node (§3) that carries a path — e.g.
"/documentation/exampledocs/examplearticle" — names exactly one file under
data/: strip the leading slash, append .json, and resolve it relative to
the archive root (data/documentation/exampledocs/examplearticle.json). That's what
Archive.parseRenderNode(dataPath:) (DocCArchive.swift, line 90) does —
and it's the single point where this container-level walkthrough hands off to everything else on
this site. Once you have that file open and decoded as Components.Schemas.RenderNode,
every field on it — kind, primaryContentSections, references,
variants, and so on — is documented one kind at a time starting from the
Kind Catalog.