#!/usr/bin/make -f
# -*- makefile -*-

#export DH_VERBOSE=1

SPHINXOPTS := -E -N

export PYBUILD_NAME=sphobjinv
export PYBUILD_TEST_ARGS=-Wignore::pytest.PytestAssertRewriteWarning -k "\
not test_clifail_convert_badoutfilename \
"

%:
	dh $@ --buildsystem=pybuild

override_dh_auto_clean:
	dh_auto_clean
	rm -rf .mypy_cache .pytest_cache

override_dh_sphinxdoc:
ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
	# The Sphinx build needs to find the 'sphobjinv' excecutable within the
	# build folder, thus we need to adjust the PATH variable a bit.
	PYTHONPATH=$(CURDIR)/src \
	PATH=$(shell realpath $$(find .pybuild -type d -name scripts | head -n1)):$(PATH) \
	     python3 -m sphinx -b html $(SPHINXOPTS) doc/source $(CURDIR)/debian/python-$(PYBUILD_NAME)-doc/usr/share/doc/python-$(PYBUILD_NAME)-doc/html
	    cp debian/_static/cc-by-4-logo-80x15.png $(CURDIR)/debian/python-$(PYBUILD_NAME)-doc/usr/share/doc/python-$(PYBUILD_NAME)-doc/html/_static
	dh_sphinxdoc
endif