.PHONY: clean clean-build clean-pyc

define PRINT_HELP_PYSCRIPT
import re, sys

for line in sys.stdin:
	match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
	if match:
		target, help = match.groups()
		print("%-20s %s" % (target, help))
endef
export PRINT_HELP_PYSCRIPT

help:
	@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)

clean: clean-build clean-pyc clean-cache ## remove all build, test, coverage and Python artifacts

clean-build: ## remove build artifacts
	rm -fr build/
	rm -fr dist/
	rm -fr .eggs/
	rm -fr docs/build/
	find . -name '*.egg-info' -exec rm -fr {} +
	find . -name '*.egg' -exec rm -fr {} +

clean-pyc: ## remove Python file artifacts
	find . -name '*.pyc' -exec rm -f {} +
	find . -name '*.pyo' -exec rm -f {} +
	find . -name '*~' -exec rm -f {} +
	find . -name '__pycache__' -exec rm -fr {} +

clean-cache:  ## remove additional cached files
	rm -fr .mypy_cache
	rm -fr .ruff_cache
	rm -fr .pytest_cache
	rm -fr .tox
	rm -fr .coverage

format: ## linting, type checking, <> is replaced with package name
	uv run ruff format .
	uv run ruff check . --fix
	uv run mypy synthbold tests

test: ## run test suite
	uv run pytest

build-docs: ## build sphinx documentation
	uv run sphinx-build -b html docs/source/ docs/build/
