Skip to main content

Track doc dependencies and detect affected docs from code changes

Project description

doctrace

OverviewFeaturesMotivationQuick StartCommandsConfigurationContributingLicense

🎺 Overview

Keep documentation in sync with code. When files change, know exactly which docs need review - and in what order.

  src/booking/handler.ts changed
               │
               v
      ┌───────────────────┐
      │ doctrace affected │
      └────────┬──────────┘
               │
               v
  ┌─────────────────────────────────┐
  │ Direct hits:                    │
  │   docs/bookings.md              │  ← has "sources: src/booking/"
  │                                 │
  │ Indirect hits:                  │
  │   docs/payments.md              │  ← requires docs/bookings.md
  └─────────────────────────────────┘
Preview
How it works

Each doc has YAML frontmatter with metadata sections:

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

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

# Booking System

How bookings work...

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.

⭐ Features

  • Impact analysis: detects which docs need review when code changes, with cascading through dependencies
  • AI-ready output: JSON output feeds AI agents to auto-update docs based on code changes
  • Interactive UI: browser dashboard to explore and visualize doc dependencies
  • Auto-gen index: generates index.md table from frontmatter metadata

❓ 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 understand each doc

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

🚀 Quick Start

Install:

brew install pipx         # if not installed (macOS/linux)
pipx install doctrace     # or: pip install doctrace

Add metadata to your docs:

---
required_docs:
  - docs/other-feature.md: hard dependency

related_docs:
  - docs/related.md: soft reference

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

# My Feature

Documentation content here...

Setup in your repo:

cd your-repo
doctrace init                        # creates doctrace.json (optional)

doctrace info docs/                  # show phases + validate refs
doctrace affected docs/ --last 5     # find docs affected by last 5 commits
doctrace preview docs/               # interactive explorer in browser

📖 Commands

doctrace info <path>                           # show phases + validate refs
doctrace affected <path> --last <N>            # list affected docs by last N commits
doctrace affected <path> --since <ref>         # list affected docs since ref (commit/tag/branch)
doctrace affected <path> --base-branch <branch># list affected docs from merge-base
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 init                                  # create doctrace.json
doctrace index <path> -o <file>                # generate index.md from frontmatter
doctrace completion <shell>                    # generate shell completion script
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.

⚙️ Configuration

Config file

doctrace.json (at repo root):

{
  "metadata": {
    "required_docs_key": "required_docs",
    "related_docs_key": "related_docs",
    "sources_key": "sources"
  }
}
Key Description
metadata.required_docs_key frontmatter key for required docs (default: "required_docs")
metadata.related_docs_key frontmatter key for related docs (default: "related_docs")
metadata.sources_key frontmatter key for source refs (default: "sources")
Shell Completion
# zsh - add to ~/.zshrc
eval "$(doctrace completion zsh)"

# bash - add to ~/.bashrc
eval "$(doctrace completion bash)"

# fish
doctrace completion fish | source

🤝 Contributing

make install    # venv + deps + pre-commit
make test       # run tests
make format     # ruff fix + format
make check      # validate ruff rules
make build      # build package
make clean      # remove venv + dist

Dev alias:

ln -sf $(pwd)/.venv/bin/doctrace ~/.local/bin/doctraced   # install
rm ~/.local/bin/doctraced                                 # remove

📜 License

This project is licensed under the MIT License.


LinkedIn Email GitHub

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.3.0.tar.gz (16.6 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.3.0-py3-none-any.whl (38.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for doctrace-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d2004356fef864e9d24ccaa5f153d1633faeb3ffdce6a3fc0d0026eeaab23f56
MD5 81281e2e2eb2f360614977cc633e66d2
BLAKE2b-256 5bf55eb76b078812ea9768f935424ef5330b57051b6f46b291e2d40e589a53ec

See more details on using hashes here.

Provenance

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

Publisher: release.yml on lucasvtiradentes/doc-trace

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.3.0-py3-none-any.whl.

File metadata

  • Download URL: doctrace-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 38.6 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ed29169b81ef713cfa2026cd8c0c11053d63afbb14ff95f6826434c43684dc51
MD5 3926e317744fc226e994c7d40cd8ae7f
BLAKE2b-256 31ac72d56e30f0fe1679cae2faa2f56d66f328306d7a51c7c9980a021ad0909d

See more details on using hashes here.

Provenance

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

Publisher: release.yml on lucasvtiradentes/doc-trace

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