Short answer: Docs from code infer the API from the implementation, which is convenient but couples the docs to the code's structure. Docs from a spec render a contract that is maintained independently, so the docs describe the intended API and can be verified. Choose by whether the code or the contract should be the authority.
What docs from code do well
They stay close to the implementation and require little separate modeling. The risk is that the code's accidental structure becomes the documented API, and the docs cannot describe a contract the code does not already have.
What docs from a spec do well
| Property | From code | From spec |
|---|---|---|
| Authority | The implementation | The contract |
| Describes intent | Indirectly | Directly |
| Verification | Against code | Against schema |
| Independent surfaces | Limited | Many |
Why the contract is the stronger source
A spec is a deliberate description of the API, so it can include responses, errors, and constraints that the code alone does not express. Rendering from it keeps the docs and the intended API aligned.
The honest tradeoff
Docs from code are lower effort for a small, stable codebase. Docs from a spec ask for modeling and pay back across the lifecycle.
This is part of the Powerduck vs Mintlify comparison. Next, read self-hosted vs cloud.
Comments
Join the discussionNo comments yet. Be the first to comment.

