Skip to main content

Track doc dependencies and detect affected docs from code changes

Project description

Overview

CLI tool that keeps documentation in sync with code in large codebases. Detects which docs are affected by code changes.

  src/booking/handler.ts changed
              │
              ▼
  ┌───────────────────────────────────┐
  │ doctrace affected docs/ --last 1   │
  └───────────────────────────────────┘
              │
              ▼
  ┌───────────────────────────────────┐
  │ Direct hits:                      │
  │   docs/bookings.md                │  ← has "related sources: src/booking/"
  │                                   │
  │ Indirect hits:                    │
  │   docs/payments.md                │  ← referenced BY docs/bookings.md
  └───────────────────────────────────┘
How it works

Each doc ends with metadata sections:

# Booking System

How bookings work...

---

related docs:
- docs/payments.md - payment integration

related sources:
- src/booking/           - booking module
- src/booking/commands/  - command handlers

When src/booking/handler.ts changes:

doctrace affected docs/ --last 1

Direct hits (1):
  docs/bookings.md       <- references src/booking/

Indirect hits (1):
  docs/payments.md       <- referenced BY docs/bookings.md

The propagation: if bookings.md might be outdated, then payments.md (which references it) might also need review.

Interactive preview explorer
Preview
Interactive panel to visualize dependencies between docs, edit content, and explore git history.

Features

  • validate - validates all referenced paths exist
  • affected - finds docs affected by code changes (with dependency ordering)
  • preview - interactive docs explorer in browser
  • lock - manages lock state for incremental analysis

Motivation

In large codebases, docs get outdated because:

  1. No one remembers which docs need updating when a file changes
  2. AI agents don't know which files to read to validate each doc

doctrace solves this by adding "hints" to each doc - related sources: tells any AI exactly what to read.

Quickstart

1. Install

pipx install doctrace

2. Add metadata to your docs

Custom style (default) - metadata at bottom
# My Feature

Documentation content here...

---

related docs:
- docs/other-feature.md - brief description

related sources:
- src/feature/           - main module
- src/feature/utils.ts   - helper functions
Frontmatter style - metadata at top
---
related docs:
  - docs/other-feature.md - brief description

related sources:
  - src/feature/         - main module
  - src/feature/utils.ts - helper functions
---

# My Feature

Documentation content here...

Config required:

{
  "metadata": {
    "style": "frontmatter"
  }
}

3. Initialize config (optional)

doctrace init    # creates .doctrace/ folder
Config options
.doctrace/
├── config.json   # required
├── lock.json     # tracks last analyzed commit
└── syncs/        # output directory (added to .gitignore)

config.json:

{
  "ignored_paths": ["**/migrations/**", "**/*.test.ts"],
  "affected_depth_limit": null,
  "metadata": {
    "style": "custom",
    "docs_key": "related docs",
    "sources_key": "related sources",
    "require_separator": true
  }
}

metadata options:

  • style: "frontmatter" (YAML at top) or "custom" (flexible format)
  • docs_key: header for doc references (default: "related docs")
  • sources_key: header for source references (default: "related sources")
  • require_separator: if true, only parse after --- (default: true, custom only)

4. Use it

doctrace validate docs/                     # validate all refs exist
doctrace affected docs/ --last 5            # find docs affected by last 5 commits
doctrace affected docs/ --since v1.0.0      # find docs affected since tag/commit/branch
doctrace preview docs/                      # interactive explorer in browser
All commands
Command Description
doctrace validate <path> validate refs exist
doctrace affected <path> --last <N> list affected docs by last N commits
doctrace affected <path> --since <ref> list affected docs since ref
doctrace affected <path> --since-lock list affected docs since lock commit
doctrace affected <path> --base-branch <branch> list affected docs from merge-base
doctrace affected <path> --verbose show changed files and match details
doctrace affected <path> --json output as JSON
doctrace preview <path> interactive explorer in browser
doctrace preview <path> --port <N> preview on custom port (default 8420)
doctrace lock update save current commit to lock.json
doctrace lock show show lock.json state
doctrace init create .doctrace/ folder
doctrace --version show version
Example output
Direct hits (3):
  docs/concepts.md
  docs/api.md
  docs/utils.md

Indirect hits (1):
  docs/overview.md <- docs/api.md

Phases (3):
  1. docs/concepts.md, docs/utils.md
  2. docs/api.md
  3. docs/overview.md

Phases show dependency order - useful for AI agents processing docs.

Development

make install           # create venv + install
make check             # lint
make test              # run tests
doctrace validate docs/ # practical test
# dev alias (doctraced)
ln -s $(pwd)/.venv/bin/doctrace ~/.local/bin/doctraced   # install
rm ~/.local/bin/doctraced                                # remove

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

doctrace-0.2.0.tar.gz (186.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

doctrace-0.2.0-py3-none-any.whl (31.7 kB view details)

Uploaded Python 3

File details

Details for the file doctrace-0.2.0.tar.gz.

File metadata

  • Download URL: doctrace-0.2.0.tar.gz
  • Upload date:
  • Size: 186.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for doctrace-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f326356202e86320ec7c7900db43165da0d1550ff202a61913c76393860dca36
MD5 6cda33abf3938f78dde8b611658be3d5
BLAKE2b-256 4f1ca9a5cf24da0aefd0c93dbf92efa6a82bf44368fd539ec315fc68c7734220

See more details on using hashes here.

Provenance

The following attestation bundles were made for doctrace-0.2.0.tar.gz:

Publisher: release.yml on lucasvtiradentes/doctrace

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file doctrace-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: doctrace-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 31.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for doctrace-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ea08d35447384de864d567723a5ad60d02d8b5dfabdcd0c3de4dcb71caafe547
MD5 6caa623a3acfa880a603c721ddcdbda5
BLAKE2b-256 1af3122b5690f054e5f366b06cdc7d9e3cf32c7629d4ff4bdf06d94969a73f0d

See more details on using hashes here.

Provenance

The following attestation bundles were made for doctrace-0.2.0-py3-none-any.whl:

Publisher: release.yml on lucasvtiradentes/doctrace

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page