Better docstrings, better AI.¶
docvet vets your Python docstrings for completeness, accuracy, and rendering compatibility — the layers beyond style and presence that tools like ruff and interrogate don't cover.
Quick Start¶
The Quality Model¶
Most tools stop at style and presence. docvet picks up where they leave off:
| Layer | Check | What It Catches | Tool |
|---|---|---|---|
| 1 | Style | Formatting, conventions | ruff D rules |
| 2 | Presence | Missing docstrings | interrogate |
| 3 | Completeness | Missing sections (Raises, Yields, Attributes) | docvet enrichment |
| 4 | Accuracy | Stale docstrings after code changes | docvet freshness |
| 5 | Rendering | Broken mkdocs output | docvet griffe |
| 6 | Visibility | Packages hidden from doc generators | docvet coverage |
Checks¶
-
Enrichment
Detects missing Raises, Yields, Attributes, and Examples sections via AST analysis. 10 rules.
-
Freshness
Flags code changes without docstring updates using git diff and git blame. 5 rules, two modes.
-
Coverage
Finds missing
__init__.pyfiles that hide packages from documentation generators. -
Griffe
Captures griffe parser warnings that break mkdocs rendering. 3 rules.
Installation¶
Usage¶
Run docvet against your entire codebase:
Or check only files with unstaged changes (the default):
Or check only staged files, ideal for pre-commit hooks:
Here's what the output looks like when findings exist:
src/myapp/utils.py:42: missing-raises Function 'parse_config' raises ValueError but Raises section is missing [required]
src/myapp/utils.py:87: stale-signature Function 'validate_input' signature changed without docstring update [required]
src/myapp/models.py:15: missing-attributes Class 'User' has 3 undocumented attributes [required]
Vetted 12 files [enrichment, freshness, coverage] — 3 findings (3 required, 0 recommended). (0.2s)
Each finding shows the file, line number, rule name, a human-readable message, and severity. The summary line confirms what was checked and how long it took. When all docstrings are clean, you see:
What's Next¶
- Set up CI Integration with GitHub Actions or pre-commit hooks.
- See the CLI Reference for full command and option documentation.
- Browse Configuration for all
pyproject.tomloptions.