Skip to content

CLI Reference

docvet provides ten subcommands. Global options are generally placed before the subcommand; discovery flags and check-specific options are placed after it.

docvet [GLOBAL OPTIONS] COMMAND [COMMAND OPTIONS]

Global Options

Option Type Default Description
--verbose flag off Show file count, per-check timing, and active checks
-q / --quiet flag off Suppress non-finding output (summary, timing, verbose details). Config warnings are always shown.
--summary flag off Print per-check quality percentages after findings
--format terminal | markdown | json terminal Output format
--output PATH stdout Write report to file
--fail-on-unavailable / --no-fail-on-unavailable flag on Exit 1 when a check listed in fail-on could not run. Either form overrides config for that run; config stays authoritative when neither is passed. See Checks that cannot run
--config PATH auto-detected Path to pyproject.toml
--version flag Show version and exit

Global options go before the subcommand: docvet --summary check --all works, while docvet check --all --summary is rejected with No such option. The exception is --verbose and --quiet, which the check subcommands and fix also accept after the subcommand name (see Quality Summary below).

When --output is specified without --format, the format defaults to markdown. When --format json is used, output is always a JSON object (even when no findings exist).

JSON Output

The --format json option produces a structured JSON object for programmatic consumption. The schema includes a findings array and a summary object:

{
  "findings": [
    {
      "file": "src/app/utils.py",
      "line": 12,
      "symbol": "my_func",
      "rule": "missing-raises",
      "message": "Function 'my_func' raises ValueError but...",
      "category": "required",
      "severity": "high"
    }
  ],
  "suppressed": [
    {
      "file": "src/app/utils.py",
      "line": 30,
      "symbol": "internal_helper",
      "rule": "missing-examples",
      "message": "Public symbol lacks an Examples section",
      "category": "recommended",
      "severity": "low"
    }
  ],
  "summary": {
    "total": 1,
    "by_category": { "required": 1, "recommended": 0, "scaffold": 0 },
    "files_checked": 42,
    "files_attempted": 42,
    "files_analyzed": 42,
    "files_failed": 0
  },
  "run": {
    "status": "findings",
    "input_errors": [],
    "exit_code": 1,
    "exit_reason": "checks configured in fail-on have findings: enrichment",
    "unavailable_checks": []
  }
}
  • Each finding has seven fields: file, line, symbol, rule, message, category, severity.
  • The severity field is derived from category: "required" maps to "high", "scaffold" maps to "medium", "recommended" maps to "low". It is a convenience alias, not a separate signal.
  • The summary object includes total, by_category (with required, recommended, and scaffold counts), files_checked, and the unique-path counts files_attempted, files_analyzed, and files_failed described under Input failures and incomplete analysis.
  • A suppressed array is included containing findings that were suppressed by inline # docvet: ignore comments. Each entry has the same seven fields as a finding.
  • A run object reports the outcome of the run itself: status ("passed", "findings", "unavailable", or "incomplete"), exit_code, exit_reason, and an unavailable_checks array listing every check that could not execute. status names which condition blocked the run, not everything that happened — a run blocked by a gate that could not execute reports "unavailable" even when it also has findings, and exit_reason then names both facts. Read summary.total to decide whether there is anything to fix, regardless of status. See Checks that cannot run.
  • Whitespace and indentation are not part of the schema contract — always parse with a JSON parser.
  • Exit codes: 0 when no active (non-suppressed) findings match a fail_on check, 1 when active findings exist in a fail_on check — or when a fail_on check could not run at all, unless the project set fail-on-unavailable = false. Input failures always exit 1; run.status distinguishes findings, unavailable, and incomplete.

Input failures and incomplete analysis

Input failures always exit 1, independently of fail-on and fail-on-unavailable. Those options control docstring findings and unavailable optional checks; they do not waive invalid inputs or failed source analysis. run.status is "incomplete" when any input fails, taking precedence over "unavailable" and "findings". Findings and unavailable-check details remain available alongside the errors.

Every JSON scan result includes run.input_errors, an array of objects with file, kind, and message. Kinds are input (invalid selection), read, decode, parse, and write (fix failure). A shared failed source is reported once per invocation, even when several checks consume it. Empty findings alone never prove a successful scan.

The summary retains files_checked as the historical selected-file count. Additional unique-path counts distinguish files_attempted (selected paths plus invalid requested targets), files_analyzed (successfully processed inputs), and files_failed (inputs with errors). Invalid explicit targets count as attempted but not selected. A scope-level failure (git discovery that cannot run, or a missing source root) reports the scope path as its one attempted and failed input. The analyzed count records successful source decoding/parsing or structural processing; it does not prove that every requested check ran. Read run.unavailable_checks to identify check prerequisites that prevented execution. The package-visibility coverage check does not require parsing Python; a syntax error alone cannot prevent that structural check from running.

When presence analysis is incomplete, presence_coverage.complete and passed are both false. percentage is null if no input was successfully analyzed; otherwise it describes only the successfully analyzed subset. Such a result cannot satisfy a coverage threshold. A successfully analyzed file with no eligible symbols retains the existing 100% convention. A legitimate empty selection exits 0, emits JSON with zero counts, and omits presence_coverage because no coverage was measured.

Selection Behavior
Missing explicit file Structured input error, exit 1
Explicit directory or non-.py file Structured input error, exit 1; use --all for a tree
Explicit file matching exclude Checked; explicit files retain their exclusion override
Empty diff, staged selection, or existing empty source tree Successful empty JSON result
Diff or staged selection outside a git repository, or without git Structured input error for the repository scope, exit 1; use --all or explicit files
Missing or invalid source root Structured input error, exit 1
Mixed valid and invalid inputs Analyze valid inputs and report the incomplete requested scope

Source loading follows Python encoding declarations, including ordinary UTF-8, UTF-8 BOM, and declared Latin-1. Invalid bytes, unknown encodings, and conflicting BOM/declarations are controlled decode failures. fix preserves the original encoding, BOM, line endings, and unaffected content. If replacement text cannot be represented safely, the source is left unchanged and a write failure is reported. --format json fix --dry-run emits its previews as a diffs array rather than mixing unified-diff text with JSON.

Migration from 2.x: accept "incomplete" in status switches, allow nullable coverage percentages, inspect complete before using a coverage value, and use files_analyzed rather than interpreting files_checked as proof of analysis. Scripts that previously relied on ignored invalid targets, skipped parse failures, or a warned empty result when git could not compute the diff (a non-git checkout such as a tarball) must handle exit 1 or select files with --all or explicit paths. Outside a repository, --all avoids the selection error but supplies no git history, so freshness is reported in run.unavailable_checks and gated by fail-on-unavailable rather than passing silently. The published pre-commit hook now adds a files: \.py$ filter because explicit non-.py targets are rejected: extensionless scripts with a Python shebang are no longer passed, while .pyi stubs were never selected by types: [python]. Valid-input finding rules, exclusion overrides, suppression, and quality denominator units remain unchanged.

Quality Summary (--summary)

The global --summary flag prints per-check quality percentages to stderr after findings. It goes before the subcommand:

docvet --summary check --all
  enrichment      96%  (8 findings)
  freshness      100%  (0 findings)
  coverage        92%  (1 findings)
  griffe         100%  (0 findings)

Only checks that actually ran appear in the output. When combined with --format json, a quality object is added to the JSON output:

docvet --summary --format json check --all
{
  "findings": [...],
  "summary": {...},
  "quality": {
    "enrichment": {"items_checked": 200, "items_with_findings": 8, "percentage": 96, "unit": "symbols"},
    "freshness": {"items_checked": 200, "items_with_findings": 0, "percentage": 100, "unit": "symbols"},
    "coverage": {"items_checked": 12, "items_with_findings": 1, "percentage": 92, "unit": "packages"},
    "griffe": {"items_checked": 15, "items_with_findings": 0, "percentage": 100, "unit": "files"}
  }
}

When --quiet and --summary are both set, the terminal summary is suppressed (--quiet wins). The machine-readable path is docvet --summary --format json check --all.

--verbose and --quiet can be placed before or after the subcommand name (dual-registered). Both positions are equivalent:

docvet --verbose check --all      # before subcommand
docvet check --all --verbose      # after subcommand — also valid
docvet check --all -q             # quiet after subcommand

When both --quiet and --verbose are specified, --quiet wins.

Output Tiers

docvet uses a three-tier output model. Findings always go to stdout; metadata goes to stderr.

Tier Trigger stderr stdout
Quiet -q / --quiet (nothing) Findings only
Default (no flags) Summary line Findings only
Verbose --verbose File count + per-check timing + summary Findings only

Parse and availability warnings always appear regardless of output tier.

Default output (zero findings):

Vetted 42 files [enrichment, freshness, coverage, griffe] — no findings. (0.3s)

Default output (with findings):

src/app/utils.py:12: missing-raises Raises section missing for ValueError [required]
src/app/utils.py:30: stale-signature Docstring may be stale (signature changed) [required]
Vetted 42 files [enrichment, freshness, coverage] — 2 findings (2 required, 0 recommended). (0.4s)

The summary line uses the brand verb "Vetted" and always includes the elapsed time and list of checks that ran. When griffe is not installed, it is omitted from the check list.

Discovery Modes

All subcommands accept the same set of discovery modes. These are mutually exclusive — use only one at a time.

Mode Description
(default) Files from git diff (unstaged changes)
--staged Files from git diff --cached (staged changes)
--all All Python files in the project
(positional) Specific files as positional arguments
--files Specific files (repeatable alternative)

Pass files as positional arguments (preferred) or with the --files flag:

docvet check src/app/utils.py src/app/models.py
docvet check --files src/app/utils.py --files src/app/models.py  # equivalent

Commands

docvet check

Run all enabled checks.

docvet check                          # unstaged changes (default)
docvet check --staged                 # staged files
docvet check --all                    # entire codebase
docvet check src/foo.py src/bar.py    # specific files

This runs presence, enrichment, freshness, coverage, and griffe (if installed) in sequence and produces a unified report.

docvet presence

Check for missing docstrings and report coverage.

docvet presence --all

Detects public symbols (modules, classes, functions, methods) that lack a docstring. Reports per-file findings and aggregate coverage statistics.

Default output (with findings):

src/myapp/utils.py:12: missing-docstring Public function has no docstring [required]
src/myapp/models.py:5: missing-docstring Public class has no docstring [required]
Vetted 10 files [presence] — 2 findings (2 required, 0 recommended), 98.0% coverage. (0.2s)

Verbose output (with coverage detail):

src/myapp/utils.py:12: missing-docstring Public function has no docstring [required]
Docstring coverage: 99/100 symbols (99.0%) — below 100.0% threshold
Vetted 10 files [presence] — 1 finding (1 required, 0 recommended), 99.0% coverage. (0.2s)

The verbose summary shows documented/total symbols, percentage, and threshold comparison when min-coverage is set.

docvet enrichment

Check for missing docstring sections.

docvet enrichment --all

Analyzes Python AST to detect missing Raises, Yields, Attributes, Examples, and other sections that should be present based on the code's behavior. 21 rules covering functions, classes, modules, and format conventions.

docvet freshness

Flag potential staleness using git history heuristics.

docvet freshness --all                # diff mode (default)
docvet freshness --all --mode drift   # drift mode
Option Type Default Description
--mode diff | drift diff Freshness check strategy

Diff mode maps git diff hunks to AST symbols and flags code changes without matching docstring updates. Fast, targeted feedback.

Drift mode uses git blame timestamps to find docstrings that haven't been updated relative to their code. Sweeps the entire codebase for timestamp-based review signals, not semantic errors.

Both modes require a git executable on PATH and a repository containing the project root that git agrees to inspect. With --all or explicit files, a prerequisite failure is reported in run.unavailable_checks and follows the configured fail-on-unavailable policy, the same probe the MCP server applies. The reason names which prerequisite failed, each with its own remedy: no git executable on PATH; a working tree outside any repository (a tarball or exported archive); a repository git refuses because of dubious ownership, where the remedy is to verify the checkout's owner and your git trust configuration rather than to trust it blindly; or any other git failure, quoted from git's own fatal: line. A generic git failure is never reported as a missing repository. The repository probe ignores an inherited GIT_DIR, so a pre-commit hook still resolves the checkout docvet runs in, and it keeps your git trust configuration untouched. This also applies to freshness inside check --all, where other available checks can still analyze files. Diff or staged file selection itself requires git and reports an input failure when it cannot determine the requested scope.

docvet coverage

Find files invisible to mkdocs.

docvet coverage --all

Walks the directory tree from each discovered file up to the source root, checking for missing __init__.py files that would make packages invisible to documentation generators.

docvet griffe

Check mkdocs rendering compatibility.

docvet griffe --all

Loads packages with the griffe parser and captures warnings that would cause broken rendering in mkdocs-material sites. Detects unknown parameters, missing type annotations, and docstring format issues.

Note

Requires the optional griffe extra: pip install docvet[griffe]. Without it the check is skipped; when griffe is listed in fail-on that exits 1 unless the project set fail-on-unavailable = false, which warns loudly and exits 0 instead — see Checks that cannot run.

docvet fix

Scaffold missing docstring sections. Runs enrichment to find missing sections, inserts placeholder content, and writes modified files. Use --dry-run to preview changes as a unified diff without modifying any files.

docvet fix                        # Fix files in git diff (default)
docvet fix --all                  # Fix entire codebase
docvet fix --staged               # Fix staged files only
docvet fix src/app.py             # Fix a specific file
docvet fix --dry-run --all        # Preview changes without writing

Unique options:

Option Description
--dry-run Show unified diff of changes without writing files

All standard discovery modes are supported (--all, --staged, positional files, --files).

Workflow: After running docvet fix, run docvet check to see scaffold-incomplete findings for each [TODO: ...] placeholder. Fill in the placeholders with real descriptions, then docvet check produces zero findings.

# Typical fix workflow
docvet fix --all                  # Insert scaffolded sections
docvet check --all                # See scaffold-incomplete findings
# ... fill in [TODO: ...] markers ...
docvet check --all                # Zero findings

docvet config

Show effective configuration with source annotations.

docvet config                     # TOML output (default)
docvet --format json config       # JSON output
docvet config --show-defaults     # same as plain `docvet config`

Prints the merged config (user values + built-in defaults) so you can see exactly which settings are active and where they come from. Each value is annotated with # (user) or # (default), or with the flag that supplied it when a global command-line flag overrode both — docvet --no-fail-on-unavailable config shows fail-on-unavailable = false # (--no-fail-on-unavailable), naming the spelling that produced the value.

TOML output (default):

[tool.docvet]
src-root = "src"  # (default)
exclude = ["tests", "scripts"]  # (default)
fail-on = ["enrichment"]  # (user)
warn-on = ["presence", "freshness", "griffe", "coverage"]  # (default)

[tool.docvet.freshness]
drift-threshold = 30  # (default)
age-threshold = 90  # (default)

[tool.docvet.enrichment]
require-raises = false  # (user)
require-yields = true  # (default)
...

The TOML output is copy-paste-ready — you can paste it directly into your pyproject.toml.

JSON output (--format json):

{
  "config": {
    "src-root": "src",
    "exclude": ["tests", "scripts"],
    "fail-on": ["enrichment"],
    "warn-on": ["presence", "freshness", "griffe", "coverage"],
    "freshness": { "drift-threshold": 30, "age-threshold": 90 },
    "enrichment": { "require-raises": false, "require-yields": true }
  },
  "user_configured": ["fail-on", "enrichment.require-raises"],
  "cli_overridden": []
}

The user_configured array lists which keys were explicitly set in your pyproject.toml. The cli_overridden array lists keys whose value came from a command-line flag instead — docvet --no-fail-on-unavailable --format json config reports "cli_overridden": ["fail-on-unavailable"], so a flag-supplied value is never mistaken for the built-in default.

When no pyproject.toml is found, a note is printed to stderr and all built-in defaults are shown.

docvet lsp

Start the LSP server for real-time diagnostics.

docvet lsp

Launches a Language Server Protocol server on stdio that publishes docstring quality diagnostics on file open and save events.

Note

Requires the optional lsp extra: pip install docvet[lsp]

docvet mcp

Start the MCP server for agentic integration.

docvet mcp

Launches a Model Context Protocol server on stdio that exposes docstring quality checks as MCP tools for AI agents. Agents can call docvet_check to run checks on files or directories, and docvet_rules to retrieve the full rule catalog.

Note

Requires the optional mcp extra: pip install docvet[mcp]

Configuration

docvet reads configuration from the [tool.docvet] section in pyproject.toml. If the section is missing, sensible defaults are used.

Specify a custom config path with:

docvet --config path/to/pyproject.toml check --all

Exit Codes

Code Meaning
0 No findings (or no findings in fail_on checks)
1 Findings detected in fail_on checks
2 Usage error (invalid arguments or options)

Inline Suppression

Suppress specific findings with inline comments. Suppression operates as a post-filter — all checks run normally, then matching findings are partitioned into suppressed.

Line-Level Suppression

Place a # docvet: ignore[rule] comment on the def or class keyword line:

def connect(host, port):  # docvet: ignore[missing-raises]
    """Connect to the server."""
    ...

Suppress multiple rules with comma separation:

def connect(host, port):  # docvet: ignore[missing-raises,missing-returns]
    """Connect to the server."""
    ...

Suppress all rules on a symbol with a blanket ignore:

def connect(host, port):  # docvet: ignore
    """Connect to the server."""
    ...

Note

The comment must be on the def/class keyword line itself — not on a decorator line. For multi-line signatures, place it on the def line: def long_name( # docvet: ignore[rule].

File-Level Suppression

Place a # docvet: ignore-file[rule] comment before the first def or class:

# docvet: ignore-file[missing-examples]


def foo():
    """Does something."""
    ...

Suppress all rules for the entire file:

# docvet: ignore-file


def foo():
    """Does something."""
    ...

Behavior

  • Exit code: Suppressed findings do NOT count toward the exit code. Only active findings determine pass/fail.
  • Verbose mode: When --verbose is active, suppressed findings are listed separately on stderr with a [suppressed] tag.
  • JSON output: --format json includes a "suppressed" array alongside "findings".
  • Invalid rules: If a suppression comment specifies a non-existent rule ID, a warning is emitted to stderr. The directive is recorded for forward-compatibility, but only matching rule IDs suppress findings — a typo will not hide anything.
  • Always active: Suppression requires no configuration toggle — it is always available.

Cross-Tool Syntax Reference

Tool Syntax Scope
ruff # noqa: E501 Line
pylint # pylint: disable=C0114 Line/block
mypy # type: ignore[attr-defined] Line
docvet # docvet: ignore[rule] Line (symbol)
docvet # docvet: ignore-file[rule] File

Examples

Check staged files before committing:

docvet check --staged

Generate a markdown report for CI:

docvet --format markdown --output report.md check --all

Produce structured JSON output for agents or CI pipelines:

docvet --format json check --all

Write JSON findings to a file:

docvet --format json --output report.json check --all

Run only the freshness drift sweep with verbose output:

docvet freshness --all --mode drift --verbose

Suppress all non-finding output (useful in scripts and CI):

docvet check --all -q

Check specific files:

docvet enrichment src/myapp/utils.py src/myapp/models.py