NB = $(sort $(wildcard examples/*.ipynb))
.PHONY: help clean lint test doc dist release

help:
	@echo "clean    remove non-source files and clean source files"
	@echo "lint     check style"
	@echo "test     run tests and check coverage"
	@echo "doc      generate HTML documentation and check links"
	@echo "dist     package (source & wheel)"
	@echo "release  package and upload to PyPI"

clean:
	git clean -Xdf
	jupyter nbconvert --inplace --ClearOutputPreprocessor.enabled=True $(NB)

lint:
	uv run flake8 --doctests --exclude=doc,.venv

# Matplotlib doesn't print to screen. Also faster.
export MPLBACKEND = agg

test:
	uv run pytest --cov=pyunlocbox --cov-report=term-missing --cov-report=html --cov-report=xml -v

doc:
	uv run sphinx-build -b html -d doc/_build/doctrees doc doc/_build/html
	uv run sphinx-build -b linkcheck -d doc/_build/doctrees doc doc/_build/linkcheck

dist: clean
	uv build
	ls -lh dist/*
	uv run twine check dist/*

release: dist
	uv run twine upload dist/*
