This file provides guidance to AI coding agents when working with code in this repository.
weav is a Jinja2 template compiler CLI. It renders templates with data from YAML files, supporting multiple data sources with deep merge, key-value parameters, and flexible template search paths.
Note: The weav package on PyPI is unrelated to this project.
# Install dependencies
uv sync --group dev
# Run the CLI
uv run weav --help
uv run weav template.j2 --data config.yaml
uv run weav template.j2 --keyval name=World
# Run tests
uv run pytest # quick test with coverage
uv run pytest tests/test_cli.py # run single test file
uv run pytest -k test_name # run specific test
uv run tox # test Python 3.11-3.12 + lint + type
# Lint and format
uv run ruff check weav tests # lint
uv run ruff format weav tests # format
uv run tox -e lint # lint via tox
uv run tox -e format # auto-fix and format
# Type checking
uv run mypy weav
uv run tox -e type
# Merge PRs (rebase only - merge and squash are disabled)
gh pr merge --rebase --delete-branch- Uses
typerfor argument parsing with type-annotated function signatures - Single command interface:
weav TEMPLATE [OPTIONS] - Shell completion for template names via
complete_template()callback - Entry point:
app = typer.Typer()→main()
compile_template()- main entry point for renderingfind_template()- locates templates in search pathsget_template_paths()- returns search order:- Package bundled templates (
weav/templates/) ./templatesin current directory~/.local/share/weav/templates(user data)~/Documents/weav/templates(user documents)
- Package bundled templates (
parse_data_args()- handlesKEY=FILEsyntax for data wrapping
deep_merge()- recursive dictionary mergeload_and_wrap()- load YAML with optional key wrapping (lists wrapped under "data" by default)mangle_keyval()- parse KEY=VAL strings
- CLI parses arguments →
compile_template() - Template located via
find_template() - YAML files loaded, wrapped, and deep-merged
- Key-value params override merged data
- Jinja2 renders template with final context
Version is defined in pyproject.toml. Access it via:
from weav import __version__Or:
from importlib.metadata import version
version("weav")Releases are triggered by pushing a git tag matching v*:
git tag -a v0.1.0 -m "Release v0.1.0"
git push origin v0.1.0Artifacts produced:
- Python wheel and sdist → GitHub Releases (not published to PyPI)
- Standalone executables for 6 platforms → GitHub Releases:
weav-linux-amd64,weav-linux-arm64weav-macos-amd64,weav-macos-arm64weav-windows-amd64.exe,weav-windows-arm64.exe
- Sigstore signatures (
.sigstore.json) for all executables except Windows ARM64