Skip to main content

Documentation as Code

Documentation as Code manages docs with software workflows: plain text, version control, pull request review, and automated publishing. It keeps runbooks and migration guides accurate by evolving them alongside the code.

Best Practice: Documentation as Code

Documentation as Code (often "docs as code") is the practice of writing and maintaining documentation using the same tools and workflows as software. Docs are written in plain-text formats such as Markdown or AsciiDoc, stored in version control next to the code, reviewed through pull requests, and published automatically by continuous integration. The approach is championed by the Write the Docs community and is now standard at many engineering organizations. The payoff is documentation that stays accurate because it evolves with the code in the same commits, is held to the same review and automation standards, and fails the build when it breaks. It also lowers the barrier to contribution: any engineer who can open a pull request can fix the docs, rather than waiting on a separate documentation team or wiki. During migrations, docs as code keeps runbooks, architecture notes, rollback procedures, and migration guides current and trustworthy precisely when teams rely on them most.

Step-by-Step Implementation Guidance

  1. Choose a plain-text format such as Markdown or AsciiDoc.
  2. Store documentation in version control, ideally alongside the relevant code.
  3. Review documentation changes in pull requests, just like code.
  4. Add automated checks: link checking, spelling, style linting, and builds.
  5. Generate and publish the site automatically through your CI/CD pipeline.
  6. Keep reference material close to its source (for example, generated from code or specs).
  7. Treat broken docs builds as build failures that block release.

Common Mistakes Teams Make When Ignoring This Practice

  • Documentation in a wiki that drifts out of sync with the code.
  • No review for docs, so errors and stale steps accumulate.
  • Manual publishing that people forget to do.
  • Binary formats that cannot be diffed or reviewed.
  • Treating docs as an afterthought outside the definition of done.

Tools and Techniques That Support This Practice

  • Static site generators: MkDocs, Docusaurus, Sphinx, Antora, Hugo.
  • Vale and markdownlint for automated style and lint checks.
  • Link checkers and CI builds that fail on broken docs.
  • Git-based review with pull request templates for docs.

How This Practice Applies to Different Migration Types

  • Cloud Migration: Keep runbooks and rollback procedures versioned so they match the migrated environment.
  • Database Migration: Document schema changes and cutover steps in the same PRs that make them.
  • SaaS Migration: Maintain integration and configuration guides that update with each release.
  • Codebase Migration: Generate API docs from code so they never lag behind the new system.

Checklist

  • Docs are written in a plain-text, diffable format.
  • Docs live in version control.
  • Doc changes go through pull request review.
  • Automated checks run on every change.
  • Publishing is automated via CI/CD.
  • Broken doc builds block release.
  • Docs are part of the definition of done.