Metadata-Version: 2.4
Name: classmap-hanthink
Version: 0.2.0
Summary: Scan Python class inheritance relationships and render them as readable maps.
Project-URL: Homepage, https://github.com/Han-think/classmap-hanthink
Author: Han-think
License: MIT
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# classmap-hanthink

`classmap-hanthink` is a small Python developer tool that scans Python files and shows class inheritance relationships as a readable tree.

Simple explanation:

> It helps you see which class is the parent and which classes are children.

Technical explanation:

> It parses Python source code with the standard `ast` module, extracts class definitions and base classes, builds a parent-to-child inheritance map, and renders the result as a text tree.

## Installation

```bash
pip install classmap-hanthink
```

## CLI Usage

Scan the current folder:

```bash
classmap .
```

Scan a specific file:

```bash
classmap examples/sample_classes.py
```

Show explanation text:

```bash
classmap . --explain
```

Show Mermaid class diagram output:

```bash
classmap . --mermaid
```

## Python Usage

```python
from classmap_hanthink import scan_path, build_inheritance_map, render_text_tree

classes = scan_path("examples/sample_classes.py")
tree = build_inheritance_map(classes)
print(render_text_tree(classes, tree))
```

## Example Output

```text
classmap report

Target: examples/sample_classes.py
Classes found: 6

Inheritance Tree

Animal [examples/sample_classes.py:1]
├── Cat [examples/sample_classes.py:13]
└── Dog [examples/sample_classes.py:5]
    └── Puppy [examples/sample_classes.py:9]

Independent Classes

- Config [examples/sample_classes.py:17]
- ExternalChild [examples/sample_classes.py:21]
```

## Development

```bash
uv sync --group dev
uv run pytest tests/ -v
uv build
```

## Release Roadmap

### v0.1.0

- Scan Python files and folders
- Extract class names, base classes, file paths, and line numbers
- Build parent-to-child inheritance relationships
- Render text tree output
- Render optional explanation output
- Render optional Mermaid classDiagram output
- Provide CLI command: `classmap`


## External Base Classes

Use `--show-external` to show classes that inherit from external or built-in base classes.

```bash
classmap examples/sample_classes.py --show-external
```

Example output:

```text
External Base Classes

dict
└── ExternalChild [examples/sample_classes.py:21]
```
