Detect and fix stale documentation before it reaches your next commit.
Project description
DocDrift
DocDrift keeps code and docs in sync before you commit.
It scans your staged git diff, finds the functions and classes you changed, looks up the related documentation, and flags docs that are now wrong, incomplete, or missing.
Why it exists
Most documentation does not fail loudly. It just drifts.
You rename a parameter, change a return value, or start raising a new exception. The code is correct, but the README still teaches the old behavior. DocDrift catches that gap before it ships.
What it does
- Detects changed functions and classes from staged git diffs
- Finds related Markdown and RST docs with semantic search
- Uses AI to check whether the docs still match the code
- Suggests updated documentation and applies fixes interactively
- Flags undocumented new symbols
- Runs locally in the CLI and in GitHub Actions with the same analysis path
Demo
git add .
python -m pip install -e .
docdrift commit
Example flow:
DocDrift scanning before commit...
+-----------------------------------------------+
| DocDrift Commit |
| 2 staged file(s) 3 changed symbol(s) ready |
+-----------------------------------------------+
Found 1 errors · 1 warnings · 1 undocumented
+-----------------------------------------------+
| ERROR |
| validate_token in auth/service.py |
| Docs: README.md:42 (Authentication) |
| Docs still promise True/False, but the code |
| now raises InvalidTokenError on failure. |
+-----------------------------------------------+
Fix this? (y/n): y
Generating fix...
+-----------------------------------------------+
| Suggested Fix |
| validate_token validates a token and raises |
| InvalidTokenError when the token is rejected. |
+-----------------------------------------------+
Apply? (y/n/e to edit): y
Fixed
Installation
Install from source:
python -m pip install -e .
Or run directly from this checkout:
./docdrift commit
Configuration
DocDrift works with:
- Groq via
GROQ_API_KEY - LM Studio compatible OpenAI-style endpoints
- Ollama compatible OpenAI-style endpoints
On first run, docdrift commit will prompt for a local endpoint if no config exists. The config is saved to .docdrift/config.json.
CLI
Check staged changes without committing:
docdrift check
Run the interactive commit flow:
docdrift commit
Rebuild the documentation index:
docdrift index
GitHub Actions
Add this workflow:
name: DocDrift
on:
pull_request:
branches: [main, master]
jobs:
check-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ./
with:
groq_api_key: ${{ secrets.GROQ_API_KEY }}
The GitHub Action uses the same analysis engine as the CLI, so local checks and PR comments stay aligned.
Pre-commit hook
Install the built-in git hook:
bash install-hook.sh
Or use the included .pre-commit-config.yaml.
Project layout
docwatcher/
├── docwatcher/
│ ├── cli.py
│ ├── engine.py
│ ├── diff_parser.py
│ ├── symbol_extractor.py
│ ├── doc_scanner.py
│ ├── embeddings.py
│ ├── llm_checker.py
│ ├── fixer.py
│ └── config.py
├── .github/workflows/docdrift.yml
├── action.yml
├── README.md
├── setup.py
└── tests/
Development
Run the package from source:
python -m docwatcher.cli check
Run tests:
python -m unittest discover -s tests
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file docdrift-2.1.0.tar.gz.
File metadata
- Download URL: docdrift-2.1.0.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bf49ca60cc0fdf745a86003e46edc0f28a48582985f2b06d25220857417bc39
|
|
| MD5 |
6f4a93b6b5d3c2178542efdc8516c83f
|
|
| BLAKE2b-256 |
5bbc355408b334779d5b2c39bb56c9b89c2f8293b052ca0f24fe8a7c7ef76734
|
File details
Details for the file docdrift-2.1.0-py3-none-any.whl.
File metadata
- Download URL: docdrift-2.1.0-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1ad92f76dd940f50c6772dbacab9617dae9083eb05fe767737c51c1c42cc595
|
|
| MD5 |
3dcb62c2e97e9f2acb6b3615feb0f8d8
|
|
| BLAKE2b-256 |
fa761a405e1b30179395d64e6e96aa0ae9867a06d6ed3cdc0befa12ec7b95731
|