# Makefile for simple installation of the Midgard Python Library

# Programs and directories
DOCSDIR = $(CURDIR)/documents/website


# Define phony targets (targets that are not files)
.PHONY: develop install format test typing doc

# Install in developer mode (no need to reinstall after changing source)
develop:
	python -m flit install -s

# Regular install, freezes the code so must reinstall after changing source code
install:
	python -m flit install --deps production

# Format code
black:
	python -m black --line-length=119 .

# Run tests
test:
	python -m pytest --doctest-modules --cov=midgard --cov-report=term-missing

typing:
	python -m mypy --ignore-missing-imports --disallow-untyped-defs --disallow-untyped-calls midgard

# Create documentation on local web page
doc:
	( cd $(DOCSDIR) && make )

# Clean all __pycache__ and other autogenerated files
clean:
	rm -rf __pycache__/
	rm -rf midgard/__pycache__/ midgard/*/__pycache__/ midgard/*/*/__pycache__/
	rm -rf tests/__pycache__/ tests/*/__pycache__/ tests/*/*/__pycache__/
	rm -rf .coverage htmlcov/
	rm -rf .mypy_cache
	rm -rf .pytest_cache
	rm -rf documents/website/docs/api/* documents/website/__pycache__/ documents/website/mkdocs.yml
