SPHINXBUILD     ?= sphinx-build
DOC_DIR         = doc

help:
	@egrep -h '\s##\s' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m  %-30s\033[0m %s\n", $$1, $$2}'

.PHONY: doc
doc: ## Build the documentation
	rm -rf public pdf
	$(SPHINXBUILD) -b html $(DOC_DIR)/source public
	$(SPHINXBUILD) -b simplepdf $(DOC_DIR)/source pdf

.PHONY: install-dev
install-dev-dependencies: ## Install all development dependencies
	pip install -r requirements-dev.txt
	pip uninstall -y xcffib

.PHONY: test
test: ## Run unit tests
	coverage run --source=xibif -m unittest discover --verbose --buffer -s xibif/tests -t . -p test_*.py
	python -m xmlrunner discover -o reports -s xibif/tests -t . -p test_*.py

.PHONY: coverage
coverage: ## Report coverage from last unit test
	coverage report
	coverage xml -o test_report_coverage.xml

.PHONY: coverage-html
coverage-html: ## Report coverage from last unit test
	coverage html -d public

.PHONY: test-coverage
test-coverage: test coverage ## run unit tests and report coverage