Skip to content

michellepace/plot-py-repo

Repository files navigation

📊 Plot Py Repo

Visualise Python repository evolution through Git history.

Context is everything with coding with LLMs. Visualise your repo to understand where and how the context is spread. Use existing charts, add your own, or analyse the raw data. See demo output.

Example Charts

Line chart showing repository evolution over time with stacked areas representing test code, source code, and code comments. Chart includes commit SHA annotations and repository footer.

Horizontal bar chart showing repository breakdown by file, categorised into test code, source code, and code comments. Chart includes repository footer with analysis details.

Generated by analysing the youtube-to-xml repository.

📈 What It Tracks

Traverses Git history commit-by-commit, analysing Python files in src/ and tests/ directories (excludes __init__.py files). Comments and docstrings are considered documentation (not code) and classified together as "code comments".

Example Python file showing line counting methodology: 25 total lines with docstrings (lines 1-4, 8), standalone comments (lines 12, 16, 20-23, 25), code lines including blanks (lines 5-7, 9-11, 13-15, 17-19, 24), and inline comment counted as code (line 9)
How lines are counted

Key principles:

  • Total lines — matches what you see in your IDE (includes blank lines)
  • Docstring lines — Module, class, and function docstrings identified via AST
  • Comment lines — Standalone # comments only (inline comments count as code)
  • Code lines — Everything else, including blank lines

📦 Install

(1) First, install the uv Python package and project manager from here.

(2) Then, install plot-py-repo to make it accessible from anywhere in your terminal:

uv tool install git+https://github.com/michellepace/plot-py-repo.git

🚀 Usage

Analyse any Python repository:

# Analyse current directory
plot-py-repo

# Analyse specific repository
plot-py-repo /path/to/your-repo

# Regenerate charts from existing CSV
plot-py-repo --csv history.csv

# Save outputs to custom directory
plot-py-repo --output-dir ./reports

# View all options
plot-py-repo --help

Example Output Files:

🛠️ Development

Clone and set up:

git clone https://github.com/michellepace/plot-py-repo.git
cd plot-py-repo
uv sync
uv run plot-py-repo /path/to/repo

Quality checks:

uv run ruff check --fix           # Lint and auto-fix
uv run ruff format                # Format code
uv run pyright                    # Type check
uv run pytest                     # Run all tests
uv run pre-commit run --all-files # Run all hooks

Tech Stack: Python 3.13+, Plotly Express, Pandas, Kaleido • See CLAUDE.md

Test Driven Development: 59 tests (5 slow, 54 unit, ~14 seconds)

🏗️ Architecture

  🔄 DATA FLOW: Git Repo → CSV → DataFrame → WebP Charts
  --

  ┌─────────────────────────────────────────────────────────────┐
  │                          cli.py                             │
  │              Parse args & orchestrate workflow              │
  └───────┬─────────────────────────────────────┬───────────────┘
          │                                     │
          │ Git Analysis                        │ Visualisation
          ▼                                     ▼
  ┌──────────────────┐              ┌─────────────────────────┐
  │  git_history.py  │              │     visualise.py        │
  │                  │              │                         │
  │  Walk commits,   │              │  Load CSV, filter,      │
  │  extract files,  │─────CSV─────▶│  delegate to charts     │
  │  classify lines, │              │                         │
  │  write CSV       │              └────────┬────────────────┘
  └────────┬─────────┘                       │
           │                                 │
           │ uses                            │ calls
           ▼                                 ▼
  ┌──────────────────┐              ┌─────────────────────────┐
  │  count_lines.py  │              │     chart_*.py          │
  │                  │              │   (3 modules)           │
  │  Pure function:  │              │                         │
  │  classify Python │              │  Transform data,        │
  │  lines into      │              │  create Plotly charts,  │
  │  code/docs/      │              │  save as WebP           │
  │  comments        │              │                         │
  └──────────────────┘              └────────┬────────────────┘
                                             │ uses
                                             ▼
                                    ┌─────────────────────────┐
                                    │       theme.py          │
                                    │                         │
                                    │  Shared theming &       │
                                    │  image export helpers   │
                                    └─────────────────────────┘

See docs/architecture/arch-03.md for detailed implementation patterns.

About

Visualise Python repository evolution through Git history (simple)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages