Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2/x] Migrate to DocC for API reference docs #257

Merged
merged 20 commits into from
Jan 7, 2022

Conversation

andrewchang-bird
Copy link
Contributor

@andrewchang-bird andrewchang-bird commented Jan 7, 2022

Stack:
πŸ“š #259 [4/x] Bump versions to 0.19.0
πŸ“š #258 [3/x] Codemod Xcode-generated file header comments
πŸ“š #257 ← [2/x] Migrate to DocC for API reference docs
πŸ“š #256 [1/x] Clean up automation pipeline

Overview

We currently use Swift Doc to generate the API reference documentation site, which was deprecated after Apple announced their fancy documentation generator at WWDC 2021 called DocC. In addition to producing great looking content pages, DocC supports arbitrary markdown-formatted articles, interactive tutorials, and works well with SwiftPM packages.

DocC’s feature set makes it easy to consolidate our existing documentation, which is scattered across the README, GitHub wiki, and API reference site. There are several benefits as well, including searchability (Google doesn’t index GitHub wiki pages) and the ability to decouple the README contents from releases.

Path Rewriting

The goal is to host the documentation site on a dedicated vanity domain for searchability and memorability. Unfortunately, DocC doesn’t support serving documentation from the root of the site and instead expects /documentation/mockingbird for articles and /tutorials/mockingbird for tutorials. Since we’ll only ever show documentation for Mockingbird on the site, it doesn’t make sense to include β€œmockingbird” in the path.

The mainline versions of Swift-DocC and Swift-DocC-Render support generating a documentation archive with a custom base path for static hosting compatibility, but this is strictly additive, e.g. /foo/bar/documentation/mockingbird (see: swiftlang/swift-docc-render#24, swiftlang/swift-docc#44).

To get the desired page paths, I’ve modified the renderer to rewrite URLs in the JSON data to the root. Currently the rewrites are hardcoded to minimize the number of changes since they are applied as a series of patches.

Syntax Highlighting

Swift-DocC-Renderer uses a lightly customized version of highlight.js for syntax highlighting code blocks which differs a bit from GitHub. I’ve patched the highlighting to make the Mockingbird testing API more readable and fix some minor issues (SR-15681).

Screen Shot 2022-01-07 at 3 59 23 AM

Test Plan

Documentation archives are built as part of the release GitHub workflow and pulled by the documentation site here: https://mockingbirdswift.com/

Screen Shot 2022-01-07 at 3 58 56 AM

Copy link
Contributor

@ryanmeisters ryanmeisters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rad

Base automatically changed from dev/andrewchang-bird/cleanup-release-automation to master January 7, 2022 23:04
@andrewchang-bird andrewchang-bird deleted the dev/andrewchang-bird/docc branch January 7, 2022 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants