Skip to content

Developer Guide

Technical documentation for contributors and developers working with Loups.


๐Ÿงญ Developer Documentation

Architecture

System design and module structure

How It Works

Detailed technical implementation

Contributing

Contribution guidelines and workflow


๐Ÿš€ Quick Start for Developers

Development Setup

# Clone repository
git clone https://github.com/jcspeegs/loups.git
cd loups

# Using devenv (recommended)
devenv shell

# Or using uv
uv venv
source .venv/bin/activate  # or .venv\Scripts\activate on Windows
uv pip install -e ".[dev]"

# Run tests
uv run python -m pytest

# Run linting
flake8 loups tests
black --check loups tests

Project Structure

loups/
โ”œโ”€โ”€ loups/                  # Main package
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ loups.py           # Core Loups class
โ”‚   โ”œโ”€โ”€ cli.py             # CLI interface
โ”‚   โ”œโ”€โ”€ match_template_scan.py
โ”‚   โ”œโ”€โ”€ thumbnail_extractor.py
โ”‚   โ”œโ”€โ”€ frame_utils.py
โ”‚   โ””โ”€โ”€ geometry.py
โ”œโ”€โ”€ tests/                  # Test suite
โ”œโ”€โ”€ docs/                   # Documentation
โ”œโ”€โ”€ devenv.nix             # Development environment
โ”œโ”€โ”€ pyproject.toml         # Project configuration
โ””โ”€โ”€ README.md

๐Ÿ›  Development Tools

Code Quality

Loups uses comprehensive linting and formatting:

Tool Purpose Config
black Code formatting pyproject.toml
flake8 Base style checking (PEP 8) .flake8
flake8-bugbear Additional bug and design problems .flake8
flake8-docstrings Docstring validation (PEP 257, D401 imperative mood) .flake8
pep8-naming PEP 8 naming conventions .flake8
flake8-quotes Quote style consistency .flake8
mccabe Cyclomatic complexity checker .flake8
isort Import sorting pyproject.toml
pytest Testing pytest.ini

Pre-commit Hooks

Pre-commit hooks ensure code quality:

# Hooks run automatically on commit
git commit -m "Your message"

# Manual run
devenv shell
pre-commit run --all-files

Active hooks: - black (formatting) - flake8 (linting) - isort (imports) - pytest (tests)


๐Ÿงช Testing

Run Tests

# All tests
uv run python -m pytest

# With coverage
uv run python -m pytest --cov=loups --cov-report=html

# Specific test file
uv run python -m pytest tests/test_loups.py

# Specific test
uv run python -m pytest tests/test_loups.py::test_function_name

# Verbose output
uv run python -m pytest -v

Writing Tests

Follow existing patterns:

import pytest
from loups import Loups

def test_loups_initialization():
    """Test Loups class initialization."""
    loups = Loups(
        video_path="test_video.mp4",
        template_path="test_template.png"
    )

    assert loups.video_path == "test_video.mp4"
    assert loups.template_path == "test_template.png"

def test_chapter_generation():
    """Test chapter generation from video."""
    loups = Loups("test_video.mp4", "template.png")
    chapters = loups.scan()

    assert len(chapters) > 0
    assert all(hasattr(ch, 'timestamp') for ch in chapters)
    assert all(hasattr(ch, 'title') for ch in chapters)

๐Ÿ“š Documentation

Build Documentation

# Serve locally
devenv shell
docs  # or: mkdocs serve

# Open browser
open http://127.0.0.1:8000

# Build static site
mkdocs build

Docstring Style

Use Google-style docstrings with imperative mood:

def process_frame(frame, template):
    """Process video frame with template matching.

    Args:
        frame: Video frame as numpy array.
        template: Template image for matching.

    Returns:
        Match confidence score (0.0 to 1.0).

    Raises:
        ValueError: If frame or template is invalid.

    Examples:
        ```python
        score = process_frame(frame, template)
        if score > 0.8:
            print("Strong match!")
        ```
    """
    # Implementation
    pass

D401 Compliance

Docstrings must start with imperative verb:

  • "Process video frame" (correct)
  • "Processes video frame" (incorrect)

Git Workflow

Branch Strategy

# Create feature branch from main
git checkout main
git pull origin main
git checkout -b feature/your-feature-name

# Make changes
git add .
git commit -m "Add feature description"

# Push to GitHub
git push origin feature/your-feature-name

# Open pull request on GitHub

Commit Messages

Follow conventional commits:

# Format
type(scope): description

# Examples
feat(cli): add batch processing command
fix(ocr): improve text extraction accuracy
docs(api): update Loups class documentation
test(thumbnail): add SSIM threshold tests
refactor(core): simplify frame processing logic

๐Ÿ”— Additional Resources


โ“ Developer FAQs

How do I add a new feature?
  1. Create issue on GitHub describing the feature
  2. Fork and create feature branch
  3. Implement with tests and docs
  4. Submit pull request
  5. See Contributing Guide
How are dependencies managed?
  • Runtime deps: pyproject.toml dependencies
  • Dev deps: devenv.nix for development environment
  • CI/CD: GitHub Actions with Nix
What Python versions are supported?

Python 3.13+ only. Uses modern Python features.

How do I debug video processing?
loups = Loups(
    video_path="video.mp4",
    template_path="template.png",
    log_level="DEBUG",
    log_file="debug.log"
)

# Check debug.log for detailed processing info