ie-schema 0.1.5

A flexible schema specification and parser for information extraction tasks.
Documentation

local_setup:
    uv tool install bump2version
    uv tool install maturin
    uv tool install ruff
    paru -S zig

full_clean: clean
    uv clean

clean:
    cargo clean
    rm -rf dist
    rm -rf docs/python_api/ie_schema.pyi

lint:
    cargo fmt
    cargo clippy --all-targets --all-features -- -D warnings
    ruff format
    ruff check .

test: lint build
    cargo test --all-features
    maturin develop --features python
    uv run pytest -q

# Python-only coverage (extension internals are Rust; use coverage-rust-pytest for that).
coverage-python:
    uv sync --group docs
    cargo run --features python --bin stub_gen
    mv ie_schema.pyi docs/python_api/ie_schema.pyi
    uv run maturin develop --features python
    mkdir -p target/coverage
    uv run pytest -q \
        --cov=ie_schema \
        --cov=tests \
        --cov-report=term-missing \
        --cov-report=xml:target/coverage/coverage.xml

# Rust (PyO3) line coverage while driving the API via pytest — requires llvm-tools + cargo-llvm-cov.
coverage-rust-pytest:
    #!/usr/bin/env bash
    set -euo pipefail
    uv sync --group docs
    rustup component add llvm-tools-preview
    if ! cargo llvm-cov --version >/dev/null 2>&1; then
        cargo install cargo-llvm-cov --locked
    fi
    cargo llvm-cov clean --workspace
    # show-env omits `export`; children (maturin, pytest) must see RUSTC_WRAPPER / LLVM_PROFILE_FILE.
    set -a
    eval "$(cargo llvm-cov show-env)"
    set +a
    cargo run --features python --bin stub_gen
    mv ie_schema.pyi docs/python_api/ie_schema.pyi
    uv run maturin develop --features python
    uv run pytest -q
    mkdir -p target/llvm-cov
    cargo llvm-cov report \
        --lcov \
        --output-path target/llvm-cov/rust-pytest.lcov \
        --ignore-filename-regex '/\.cargo/registry/'

coverage: coverage-python coverage-rust-pytest

commit: test
    git add .
    git commit -m "$(opencode run -m "${OPENROUTER_QUICK_MODEL:-openrouter/google/gemma-4-26b-a4b-it:free}" "Here is a git diff of staged changes. Write ONLY a single conventional commit message (type: description), no explanation, no backticks, no quotes: $(git diff --cached)" 2>/dev/null | tail -1)"
    git push origin

check-clean-stage:
    # Fail if there are staged (uncommitted) changes
    @git diff --cached --quiet || (echo "Error: You have staged but uncommitted changes." && exit 1)

check-clean:
    # Fail if the working tree is dirty at all (staged + unstaged + untracked)
    @test -z "$(git status --porcelain)" || (echo "Error: Working tree is dirty." && exit 1)

push: test check-clean
    git push origin

build: clean
    cargo build
    cargo run --features python --bin stub_gen
    mv ie_schema.pyi docs/python_api/ie_schema.pyi
    maturin build --out dist --zig

build_release: clean
    cargo build --release
    cargo run --release --features python --bin stub_gen
    mv ie_schema.pyi docs/python_api/ie_schema.pyi
    maturin build --release --zig --out dist

publish_pypi: build_release
    uv publish
    
publish_crate: build_release
    cargo publish

publish: publish_pypi publish_crate
    
docs: build
    uv sync --group docs
    uv run sphinx-build -b html docs docs/_build/html
    firefox docs/_build/html/index.html