The Swift-DocC compilation process follows a discrete, sequential pipeline consisting of three main phases: Discovery, Analysis and Registration, and Rendering. Understanding these phases helps in organizing documentation catalogs and troubleshooting how symbols and markup are integrated into the final output.
1. Discovery
DocC identifies inputs from command-line arguments and the documentation catalog (.docc directory). Discovered inputs include:
- Markup, tutorials, and assets: Must be inside a
.docc directory. - Symbol graph files: Can be inside a
.docc directory or provided via command-line arguments. - Meta information: Can be provided via an optional top-level
Info.plist inside a .docc directory or via command-line arguments. - Render template customizations: Must be inside a
.docc directory.
2. Analysis and Registration
DocC builds an in-memory topic graph using the discovered inputs:
- Symbol Registration: Machine-generated symbol graph files are loaded first. Each symbol becomes a documentation node (a topic).
- Markup Analysis: Markup files (articles, tutorials) are converted to documents and added to the graph. These can extend existing symbol documentation.
- External Resolution: Symbols referenced from other frameworks are fetched and added if resolvable.
- Curation: Authors can manually curate the experience by adding Topics and See Also sections to articles. DocC also performs automatic curation for uncurated symbols and checks for dead links.
3. Rendering
DocC converts the in-memory model into a persistable format:
- Each
DocumentationNode is translated into a RenderNode (containing hierarchy, meta info, resolved links, and processed markup). JSONEncodingRenderNodeWriter encodes these nodes into JSON files.- The output is written to a file hierarchy (typically under
.docc-build) where each JSON file represents a single topic.