Metadata-Version: 2.4
Name: docstr-health
Version: 0.1.5
Summary: Health score and visualization for Python projects
Keywords: docstring,documentation,code-quality,pep257,linter,cli,analysis,coverage
Author: Mihail Sergeenko
License-Expression: Apache-2.0
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Documentation
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Environment :: Console
Classifier: License :: OSI Approved :: Apache Software License
Requires-Dist: rich>=15.0.0
Maintainer: Mihail Sergeenko
Requires-Python: >=3.11
Project-URL: Homepage, https://github.com/PurpleSwtr/docstr-health
Project-URL: Repository, https://github.com/PurpleSwtr/docstr-health.git
Project-URL: Documentation, https://github.com/PurpleSwtr/docstr-health#readme
Project-URL: Issues, https://github.com/PurpleSwtr/docstr-health/issues
Project-URL: Changelog, https://github.com/PurpleSwtr/docstr-health/blob/main/CHANGELOG.md
Description-Content-Type: text/markdown

<p align="center">
  <img src="https://raw.githubusercontent.com/PurpleSwtr/docstr-health/main/docs/assets/logo.png" alt="Docstr-Health" width="100%"/>
</p>

<p align="center">
  <a href="https://pypi.org/project/docstr-health/">
    <img src="https://img.shields.io/pypi/v/docstr-health" alt="PyPI version">
  </a>
  <a href="https://pypi.org/project/docstr-health/">
    <img src="https://img.shields.io/pypi/pyversions/docstr-health" alt="Python versions">
  </a>
  <a href="https://github.com/PurpleSwtr/docstr-health/blob/main/LICENSE">
    <img src="https://img.shields.io/github/license/PurpleSWTR/docstr-health?color=2E7D32" alt="License">
  </a>
  <a href="https://pypi.org/project/docstr-health/">
    <img src="https://img.shields.io/pypi/dm/docstr-health" alt="Downloads">
  </a>
  <a href="https://github.com/PurpleSwtr/docstr-health/actions/workflows/tests.yml">
    <img src="https://github.com/PurpleSwtr/docstr-health/actions/workflows/tests.yml/badge.svg" alt="tests">
  </a>
  <a href="https://github.com/PurpleSwtr/docstr-health">
    <img src="https://img.shields.io/github/stars/PurpleSwtr/docstr-health?style=social" alt="GitHub stars">
  </a>
</p>
<p align="center">
  <a align="center" href="https://madebyhuman.iamjarl.com"><img src="https://madebyhuman.iamjarl.com/badges/made-white.svg" alt="Made by Human" width="180" height="40">
  </a>
</p>

CLI and CI tool for fast docstring quality checks in Python projects. Detailed statistics for functions, classes, modules, and the whole project.

Analyze documentation quality locally, from Git repositories, or from PyPI packages.

<img src="https://raw.githubusercontent.com/PurpleSwtr/docstr-health/main/docs/assets/preview.gif" alt="Preview" />

## Table of Contents

- [Features](#features)
- [How It Compares](#how-it-compares)
  - [When to use docstr-health](#when-to-use-docstr-health)
- [Installation](#installation)
- [Documentation](#documentation)
- [Usage](#usage)
  - [Scan a local project](#scan-a-local-project)
  - [Scan a Git repository](#scan-a-git-repository)
  - [Scan a PyPI package](#scan-a-pypi-package)
  - [Compact mode](#compact-mode)
  - [Include module docstrings](#include-module-docstrings)
  - [All flags](#all-flags)
- [Output](#output)
  - [Docstring statuses](#docstring-statuses)
  - [Module statuses](#module-statuses)
- [Configuration](#configuration)
- [Contributing](#contributing)
- [License](#license)
- [Acknowledgements](#acknowledgements)

---

## Features

- **Local & remote scanning:** local directories, Git repositories, and PyPI packages
- **Multi-level quality grading:** each object gets `bad`, `good`, `special`, or `epic` status
- **Detailed statistics:** breakdown by functions, classes, modules, and overall project
- **CI & pre-commit ready:** `--ci` mode with configurable failure level, plus a ready-to-use pre-commit hook
- **Fast AST-based analysis:** parses Python code without importing it
- **Rich terminal UI:** color-coded panels, tables, and progress bars
- **Flexible configuration:** tune thresholds, symbols, colors, and keywords via `pyproject.toml`
- **Docstring style awareness:** detects common sections used by PEP 257, Google, Sphinx, and NumPy styles
- **Clickable file navigation:** jump to files directly from supported terminals/IDEs

---

## How It Compares

| Feature                          | docstr-health                          | pydoclint                               | darglint / darglint2                    | interrogate                      | docstr_coverage            |
| -------------------------------- | -------------------------------------- | --------------------------------------- | --------------------------------------- | -------------------------------- | -------------------------- |
| **Scope**                        | Docstring **quality** grading          | Docstring **correctness** vs signature  | Docstring **correctness** vs signature  | Docstring **coverage** (%)       | Docstring **coverage** (%) |
| **Quality levels**               | ✓ `bad`, `good`, `special`, `epic`     | ✗ Pass/fail only                        | ✗ Pass/fail only                        | ✗ Percentage only                | ✗ Percentage only          |
| **Detailed stats**               | ✓ Functions, classes, modules, project | ✗                                       | ✗                                       | ✓ Coverage totals                | ✓ Coverage totals          |
| **Rich terminal UI**             | ✓ Rich panels, colors, symbols         | ✗ Plain text                            | ✗ Plain text                            | ✗ ASCII table                    | ✗ Plain text               |
| **Remote scanning (Git / PyPI)** | ✓ Built-in                             | ✗                                       | ✗                                       | ✗                                | ✗                          |
| **CI mode / exit code**          | ✓ `--ci` with `failure_level`          | ✓                                       | ✓                                       | ✓                                | ✓                          |
| **Pre-commit hook**              | ✓                                      | ✓                                       | ✓                                       | ✓                                | ✓                          |
| **Configurable rules**           | ✓ `pyproject.toml`                     | ✓ CLI flags + config                    | ✓ `.darglint` config                    | ✓ `pyproject.toml` / `setup.cfg` | ✓ `.docstr.yaml`           |
| **Performance**                  | ✓ Fast (AST-based)                     | ✓ Fast                                  | ✗ Slow (CYK parser)                     | ✓ Fast                           | ✓ Fast                     |
| **Docstring styles**             | ✓ PEP 257, Google, Sphinx, NumPy       | ✓ Google, Sphinx, NumPy                 | ✓ Google, Sphinx, NumPy                 | ✗ Coverage only                  | ✗ Coverage only            |
| **Documentation**                | ✓                                      | ✓                                       | ✓                                       | ✓                                | ✓                          |
| **Signature validation**         | ✗ Planned                              | ✓ Checks args/returns/raises match code | ✓ Checks args/returns/raises match code | ✗                                | ✗                          |
| **Coverage badge generation**    | ✗ Planned                              | ✗                                       | ✗                                       | ✓ SVG/PNG                        | ✓ SVG                      |

### When to use docstr-health

- You want to **measure documentation depth**, not just its existence
- You want a **quick visual health score** for your project's documentation
- You need to **scan remote repositories** (Git, PyPI) without cloning manually
- You want **color-coded terminal output** with rich formatting
- You want to **enforce docstring quality in CI/pre-commit** with a configurable failure threshold.

---

## Installation

```shell
pip install docstr-health
```

---

## Documentation

Full documentation is available on the [documentation website](https://purpleswtr.github.io/docstr-health/).

---

## Usage

### Scan a local project

```shell
docstr-health /path/to/project
```

If no path is given, the current directory is used.

### Scan a Git repository

```shell
docstr-health --repo-url https://github.com/user/repo.git
```

The repository is cloned into a cache directory and scanned automatically.

### Scan a PyPI package

```shell
docstr-health --pypi-package requests
```

Downloads and scans the package from PyPI.

### Use in CI / pre-commit

```shell
docstr-health --ci --threshold-warning 60
```

```yaml
repos:
  - repo: https://github.com/PurpleSwtr/docstr-health
    rev: v0.1.5
    hooks:
      - id: docstr-health
```

### Compact mode

Display only the summary statistics without the per-function listing:

```shell
docstr-health --compact
```

### Include module docstrings

Include `__doc__` of the modules themselves in the analysis:

```shell
docstr-health --doc-modules
```

### All flags

| Flag                  | Description                                                  |
| --------------------- | ------------------------------------------------------------ |
| `--repo-url`          | Scan a remote Git repository                                 |
| `--pypi-package`      | Scan a remote PyPI package                                   |
| `--cache-dir`         | Custom cache directory for remote repos                      |
| `--no-cache`          | Do not cache remote repositories                             |
| `--compact`           | Show only summary statistics                                 |
| `--doc-modules`       | Include module `__doc__` strings                             |
| `--ignore-tests`      | Skip test files and directories                              |
| `--short-names`       | Replace full file paths with short names                     |
| `--ci`                | CI mode: suppress output, exit 1 if status ≤ `failure_level` |
| `--threshold-bad`     | Threshold for bad status (default: 80)                       |
| `--threshold-warning` | Threshold for warning status (default: 60)                   |
| `--threshold-special` | Threshold for special status (default: 50)                   |
| `--threshold-epic`    | Threshold for epic status (default: 50)                      |
| `--version`           | Show version and exit                                        |

## Output

### Docstring statuses

| Status    | Symbol | Meaning                                                      |
| --------- | ------ | ------------------------------------------------------------ |
| `bad`     | ✗      | Missing or empty docstring                                   |
| `good`    | ✓      | Docstring exists but only has a description                  |
| `special` | ★      | Contains parameter docs (`Args:`,`:param`, `Returns:`, etc.) |
| `epic`    | ♥      | Contains advanced sections (`Raises:`, `Examples:`)          |

### Module statuses

The overall module status is computed from the individual function statuses:

- **bad:** all or most functions are undocumented
- **warning:** some functions are undocumented
- **good:** all functions documented, few special sections
- **special:** >50% of functions have parameter documentation
- **epic:** >50% of functions have advanced documentation (returns, raises, examples)

## Configuration

Defaults ship with the package. Override anything you need in `pyproject.toml` (or use CLI flags):

```toml
[tool.docstr-health]
excluded = [".venv", "__init__", "__pycache__"]
threshold_bad = 80
threshold_warning = 60
```

All available options and their defaults: see [`config.toml`](./docstr_health/config.toml).

## Contributing

We welcome and appreciate all contributions!

Before you begin, please read [Contributing Guide](https://github.com/PurpleSwtr/docstr-health/blob/main/CONTRIBUTING.md). It covers coding standards, branching strategy, and the Pull Request process.

## License

Apache License 2.0 © Mihail Sergeenko. See [LICENSE](https://github.com/PurpleSwtr/docstr-health/blob/main/LICENSE) for
details.

## Acknowledgements

Huge thanks to [Textualize](https://github.com/Textualize) for [Rich](https://github.com/Textualize/rich), library powering this project.
