hi Swifties! (is it too late to open these announcements with Happy New Year?)
anyway, Unidoc 0.20 is now available, and below i’m going to outline some of the most exciting improvements to our Swift documentation engine.
Deprecating the FNV-1 suffix (“DocC hashes”)
FNV-1 hashes are one of the oldest pain points of Swift Documentation, and Unidoc 0.20 ships with a greatly empowered symbol link syntax that allows you to write human-readable link disambiguations in virtually all scenarios where FNV-1 hashes would have been previously required.
How powerful is it?
As a pilot run, I migrated nine libraries to the human-readable link syntax, purging scores of FNV-1 hashes in the process.
- swift-bson
- swift-dom
- swift-grammar
- swift-hash
- swift-ip
- swift-jpeg
- swift-json
- swift-png
- swift-unixtime
We also updated all of the markdown sources for the articles on the SwiftOnServer website to use the new disambiguation syntax, eliminating a huge number of FNV-1 hashes there as well.
Although we anticipate there are still cases where FNV-1 hashes are necessary, so far we have not encountered a single instance of an ambiguous symbol link that could not be rewritten using the human-readable syntax.
We’ve previously pitched the base syntax on Forums, but these are the two main additions in Unidoc 0.20:
Disambiguating protocol requirements and default implementations
public
protocol ExampleProtocol {
func f()
}
extension ExampleProtocol {
public
func f() {}
}
As a straightforward extension to existing phylum-based disambiguation, you can now explicitly select protocol requirements using the [requirement]
(or [requirement: true]
) filter, or exclude them (thus preferring default implementations) using [requirement: false]
.
``ExampleProtocol.f [requirement]``
``ExampleProtocol.f [requirement: false]``
To use custom link text, you can replace the spaces in the links with hyphens to encode them with URI-friendly characters.
[custom text](ExampleProtocol.f-[requirement])
[custom text](ExampleProtocol.f-[requirement:false])
Type signature disambiguation
It is now possible to disambiguate methods, initializers, subscripts, and properties using type signature disambiguation, which allows you to filter overloads by specifying partial type signatures. (This builds on work by @ronnqvist in DocC.)
``Int.init(_:) (Float)``
``Int.init(_:) (Double)``
You can omit irrelevant argument and return types using the underscore character (_
), to provide only the types that are different between overloads.
``Example.f(x:y:) (_, String)``
``Example.f(x:y:) (_, Substring)``
``Example.f(x:y:) (_, _) -> (_, _)``
``Example.f(x:y:) -> (_, Int)``
Arrays, Dictionaries, Optionals, implicitly unwrapped Optionals, metatypes, generic types, variadics, tuples, closures, suppressed conformances, some
and any
protocol composition types, and parameter packs are all supported.
``Example.g(_:) ([Int])``
``Example.g(_:) ([Int: String])``
``Example.g(_:) ([Int: String].Type)``
``Example.g(_:) (Int...)``
``Example.g(_:) (Set<Int>)``
``Example.g(_:) (Int?)``
``Example.h(_:) (Int!)``
``Example.g(_:) (Dictionary<Int, Int>.Index)``
``Example.g(_:) (Sendable & CustomStringConvertible)``
``Example.g(_:) ((Int, Int))``
``Example.g(_:) ((Int) -> Int)``
``Example.g(_:) (~Copyable)``
Custom link text can be used by removing optional spaces and replacing structural spaces with hyphens (-
).
[custom text](Int.init(_:)-(Float))
[custom text](Int.init(_:)-(Double))
Composing features
You can combine multiple disambiguation mechanisms by specifying filters after type signatures:
``Example.g(_:) (Int64, _) -> Int64 [static func]``
[custom text](Example.g(_:)-(Int64,_)->Int64-[static-func])
Do note that the latter is a valid markdown link (as the brackets and parentheses are balanced), the Swift Forums highlighter is just failing to highlight it correctly.
UCF symbol links are a superset of the DocC symbol link syntax, so your existing DocC links will just work when rendered with Unidoc.
You can read our recipe page for a progressive rundown on how to use the expanded link syntax:
Apple Developer-style documentation themes
The new Apple Developer-style documentation theme that was previously added to Swiftinit is part of the Unidoc 0.20 release.
Installing Unidoc
We now distribute prebuilt binaries for a number of platforms, which are available as .tar.gz
archives on the project GitHub README.
From there, you can get started with our guide:
Other Improvements
- In the list of package consumers, Unidoc now displays the version (git tag) associated with the most recent release of the downstream package (Dependency versioning by tayloraswift · Pull Request #356 · tayloraswift/swift-unidoc · GitHub)
- Clicking on a sidebar link to an extended type now scrolls you directly to that module’s extensions instead of depositing you at the top of the page (link directly to a module's extensions from cross-module sidebar links by tayloraswift · Pull Request #374 · tayloraswift/swift-unidoc · GitHub)
- Unidoc can now (lazily) generate redirects to historical documentation when API is removed in a subsequent release. The redirect is available if at least one trustworthy client (Googlebot, Bingbot, or a logged-in user) had visited the deleted page before the symbol was removed (public SEO dashboard by tayloraswift · Pull Request #358 · tayloraswift/swift-unidoc · GitHub, Historical redirects by tayloraswift · Pull Request #361 · tayloraswift/swift-unidoc · GitHub)
- Unidoc now records the git commit date in the binary symbol graph format, if known (Symbol graph date by tayloraswift · Pull Request #371 · tayloraswift/swift-unidoc · GitHub)
- Unidoc now prefers non-inherited symbols when disambiguating symbol links and breaks ties by preferring the symbol with more documentation (prefer non-inherited symbols when disambiguating links by tayloraswift · Pull Request #381 · tayloraswift/swift-unidoc · GitHub)
- Plugin logs can now be viewed through the HTML UI (Frontend accessible logging by tayloraswift · Pull Request #363 · tayloraswift/swift-unidoc · GitHub)
- Unidoc can now be built in distributed configuration, with creating binaries for frontend and backend servers (server modularization by tayloraswift · Pull Request #367 · tayloraswift/swift-unidoc · GitHub)
- Adds a utility command
unidoc list-assets
(add a utility command 'unidoc list-assets' by tayloraswift · Pull Request #370 · tayloraswift/swift-unidoc · GitHub) - Unidoc now compresses symbol graphs before uploading them to a server (compress symbol graph uploads by tayloraswift · Pull Request #354 · tayloraswift/swift-unidoc · GitHub)
Notable Bugfixes
- Deduplicate macro synthesized decls (Deduplicate macro synthesized decls by tayloraswift · Pull Request #352 · tayloraswift/swift-unidoc · GitHub)
- Ignore validation errors resulting from (lib/SymbolGraphGen) types should not inherit extension members from `@available(*, unavailable)` conformances · Issue #76877 · swiftlang/swift · GitHub (ignore validation errors resulting from https://github.com/swiftlang/swift/issues/76877 by tayloraswift · Pull Request #353 · tayloraswift/swift-unidoc · GitHub)
- Multi-column DocC layouts no longer overflow their parent containers (#390)
Next Steps
One common piece of feedback we’ve gotten so far is that Unidoc is a great documentation engine, but not a great tool for writing documentation. Although the local iteration story has made great strides in the past year, we are aware that many still feel that Unidoc is primarily a “deploy to server system” and that it imposes a lot of complexity on users who are simply interested in editing docs and previewing changes on their local machine.
In the next year, we intend to streamline the local editing experience, and enable authors to do more locally without necessarily taking on the responsibility of managing a long-lived local documentation database.