Developer docs done right#
Existing developer documentation systems largely fall into two buckets:
Docs live separately from source code. Examples: Confluence, Notion.
Docs are generated from source code. Examples: Sphinx, Rust spec.
Both approaches have pros and cons. When docs are generated from source code:
Docs are more likely to be updated when the code changes.
Have extensive support for cross reference to other parts of the codebase.
Are immediately available to the developers who read and change the code.
Developers need to learn the markup language.
It’s hard to tell if the docs are going to render properly during the editing.
There’s an extra friction between reading generated docs to editing them, which oftentimes leads to typos not being fixed and less readability improvements.
Changes are likely bound to the same code review process as the actual code changes, that further increases friction for small edits.
When docs are in a separate system, say Notion:
WYSIWYG editors are easy to use and have a low entrance cost.
Editing can done during reading, which increases collaboration and improves text quality over time.
Non-developers can update the docs too.
It’s hard to reference and cross reference class and code snippets.
Docs are harder to discover during editing code.
Docs are always stale when code changes.
The perfect documentation system has to be a mix of both approaches:
Developers should immediately see the rendered docs (and rendering issues) while editing code.
Readers should be able to edit the docs while reading without searching for the respective docs origin in code.
Doc changes need to become immediately available for other readers.
Few projects are trying to solve this:
Here are the high level components that make this system work regardless of implementation.
Docs renderer. Extracts doc strings from source code, resolves cross references, applies markup, and generates HTML pages.
Docs server. Serves generated docs to the readers. Links docs sections to the source doc strings in the source code.
Online docs editor. Allows users to make edits while reading, publishes the new version in near real time.
Synchronizer. Propagates online edits back to the source code. Updates only the doc strings, and keeps formatting consistent.
VCS integration. Commits the changes and pushes them to a central repository. Records who and when made the changes.
Code review integration. Creates pull request with the new edits.
Code review streamliner. Detects pull requests that only change docs and automatically approved and merges the request.