Files
leo-claude-mktplace/plugins/doc-guardian/commands/doc-coverage.md
lmiranda 9698e8724d feat(plugins): implement Sprint 4 commands (#241-#258)
Sprint 4 - Plugin Commands implementation adding 18 new user-facing
commands across 8 plugins as part of V5.2.0 Plugin Enhancements.

**projman:**
- #241: /sprint-diagram - Mermaid visualization of sprint issues

**pr-review:**
- #242: Confidence threshold config (PR_REVIEW_CONFIDENCE_THRESHOLD)
- #243: /pr-diff - Formatted diff with inline review comments

**data-platform:**
- #244: /data-quality - DataFrame quality checks (nulls, duplicates, outliers)
- #245: /lineage-viz - dbt lineage as Mermaid diagrams
- #246: /dbt-test - Formatted dbt test runner

**viz-platform:**
- #247: /chart-export - Export charts to PNG/SVG/PDF via kaleido
- #248: /accessibility-check - Color blind validation (WCAG contrast)
- #249: /breakpoints - Responsive layout configuration

**contract-validator:**
- #250: /dependency-graph - Plugin dependency visualization

**doc-guardian:**
- #251: /changelog-gen - Generate changelog from conventional commits
- #252: /doc-coverage - Documentation coverage metrics
- #253: /stale-docs - Flag outdated documentation

**claude-config-maintainer:**
- #254: /config-diff - Track CLAUDE.md changes over time
- #255: /config-lint - 31 lint rules for CLAUDE.md best practices

**cmdb-assistant:**
- #256: /cmdb-topology - Infrastructure topology diagrams
- #257: /change-audit - NetBox audit trail queries
- #258: /ip-conflicts - Detect IP conflicts and overlaps

Closes #241, #242, #243, #244, #245, #246, #247, #248, #249,
#250, #251, #252, #253, #254, #255, #256, #257, #258

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 12:02:26 -05:00

3.3 KiB

description
description
Calculate documentation coverage percentage for functions and classes

Documentation Coverage

Analyze codebase to calculate documentation coverage metrics.

Process

  1. Scan Source Files Identify all documentable items:

    Python:

    • Functions (def)
    • Classes
    • Methods
    • Module-level docstrings

    JavaScript/TypeScript:

    • Functions (function, arrow functions)
    • Classes
    • Methods
    • JSDoc comments

    Other Languages:

    • Adapt patterns for Go, Rust, etc.
  2. Determine Documentation Status For each item, check:

    • Has docstring/JSDoc comment
    • Docstring is non-empty and meaningful (not just pass or TODO)
    • Parameters are documented (for detailed mode)
    • Return type is documented (for detailed mode)
  3. Calculate Metrics

    Coverage = (Documented Items / Total Items) * 100
    

    Levels:

    • Basic: Item has any docstring
    • Standard: Docstring describes purpose
    • Complete: All parameters and return documented
  4. Output Format

## Documentation Coverage Report

### Summary
- Total documentable items: 156
- Documented: 142
- Coverage: 91.0%

### By Type
| Type | Total | Documented | Coverage |
|------|-------|------------|----------|
| Functions | 89 | 85 | 95.5% |
| Classes | 23 | 21 | 91.3% |
| Methods | 44 | 36 | 81.8% |

### By Directory
| Path | Total | Documented | Coverage |
|------|-------|------------|----------|
| src/api/ | 34 | 32 | 94.1% |
| src/utils/ | 28 | 28 | 100.0% |
| src/models/ | 45 | 38 | 84.4% |
| tests/ | 49 | 44 | 89.8% |

### Undocumented Items
- [ ] src/api/handlers.py:45 `create_order()`
- [ ] src/api/handlers.py:78 `update_order()`
- [ ] src/models/user.py:23 `UserModel.validate()`

Options

Flag Description Default
--path <dir> Scan specific directory Project root
--exclude <glob> Exclude files matching pattern **/test_*,**/*_test.*
--include-private Include private members (_prefixed) false
--include-tests Include test files false
--min-coverage <pct> Fail if below threshold none
--format <fmt> Output format (table, json, markdown) table
--detailed Check parameter/return docs false

Thresholds

Common coverage targets:

Level Coverage Description
Minimal 60% Basic documentation exists
Good 80% Most public APIs documented
Excellent 95% Comprehensive documentation

CI Integration

Use --min-coverage to enforce standards:

# Fail if coverage drops below 80%
claude /doc-coverage --min-coverage 80

Exit codes:

  • 0: Coverage meets threshold (or no threshold set)
  • 1: Coverage below threshold

Example Usage

/doc-coverage
/doc-coverage --path src/
/doc-coverage --min-coverage 85 --exclude "**/generated/**"
/doc-coverage --detailed --include-private

Language Detection

File extensions mapped to documentation patterns:

Extension Language Doc Format
.py Python Docstrings (""")
.js, .ts JavaScript/TypeScript JSDoc (/** */)
.go Go // comments above
.rs Rust /// doc comments
.rb Ruby # comments, YARD
.java Java Javadoc (/** */)