Skip to content

Lesson 7 of 9 · 24m

Docs-as-Code Workflow

Versioned documentation close to the code enables review, automation, and release coordination — if the workflow is designed instead of merely installed.

Docs-as-code is often reduced to "Markdown in git." That misses the point. The real win is that documentation can participate in the same discipline as software: review, automated checks, reproducible builds, release gates, and history. The failure mode is also the same as software: tooling without ownership becomes a pile of broken scripts.

Put docs where change happens

A practical layout keeps operational documentation near the systems it describes:

repo/
  docs/
    operate/
    reference/
    tutorials/
    assets/
  mkdocs.yml
  src/

When a pull request changes a flag, the documentation diff can sit beside the code diff. Reviewers can see both. This does not mean every document must live in the application repo — cross-product documentation may need its own — but distance should be a deliberate tradeoff, not an accident.

Make the build boring

Documentation tooling should be reproducible and uninteresting:

# mkdocs.yml
site_name: Operations Docs
docs_dir: docs
nav:
  - Operate:
      - Rotate secrets: operate/rotate-secrets.md
      - Roll back a release: operate/rollback-release.md
  - Reference:
      - Runtime flags: reference/runtime-flags.md
markdown_extensions:
  - admonition
  - tables
  - toc:
      permalink: true

Pin the generator and plugins. If local preview requires a global unpinned install, every dependency upgrade becomes a surprise. A requirements-docs.txt or package lockfile is not ceremony; it is how you keep the build reproducible.

Automate the checks that encode policy

Useful checks are specific:

# .github/workflows/docs.yml (conceptual)
steps:
  - run: pip install -r requirements-docs.txt
  - run: mkdocs build --strict
  - run: lychee --offline --exclude-loopback docs 'site/**/*.html'
  - run: vale docs

mkdocs build --strict catches missing pages and broken internal links. A link checker catches decay. A prose linter can enforce terminology and detect accidentally committed TODOs. Do not automate taste; automate constraints the team agreed on.

Review documentation like behavior

A review checklist should ask:

  • Does the documented command match the code change?
  • Are defaults, version constraints, and rollback behavior updated?
  • Did examples change semantically even if syntax still parses?
  • Are new pages linked from navigation and relevant existing pages?
  • Does the page still serve the task it claims to serve?

Rubber-stamping a diff because it is "just docs" is how incorrect operational instructions reach production.

Preview is part of correctness

Navigation depth, table wrapping, admonition rendering, and mobile behavior are not visible in raw Markdown. Build previews for pull requests when possible. At minimum, run the local server before merging structural changes. Writers need fast feedback; a slow documentation build teaches people to stop checking.

Field notes

  • Monorepo adjacency helps only if reviewers enforce docs updates; proximity without process is wishful thinking.
  • Keep generated reference artifacts out of hand-edited trees, or mark generated sections clearly so edits are not overwritten.
  • Treat search configuration as part of the build; a beautiful site with bad search still fails retrieval.
  • Versioned docs need branch and redirect strategy before launch, not after the first breaking release.

Was this lesson helpful?

Sign in to rate