#!/usr/bin/make -f

export PYBUILD_NAME=docformatter
export PYBUILD_TEST_ARGS=-v -k "not TestEndToEnd"

%:
	dh $@ --with python3,sphinxdoc --buildsystem=pybuild

execute_after_dh_auto_clean:
	rm -rf .pytest_cache
	rm -f $(PYBUILD_NAME).1

execute_after_dh_auto_install:
	PYTHONPATH=$(CURDIR)/src help2man debian/python3-$(PYBUILD_NAME)/usr/bin/$(PYBUILD_NAME) \
	  --no-info \
	  --name "$(shell grep '^Description' debian/control | head -n 1 | cut -d: -f2)" \
	  > $(PYBUILD_NAME).1

override_dh_auto_test:
ifeq ($(filter nocheck,$(DEB_BUILD_PROFILES)),)
	dh_auto_test
endif

override_dh_sphinxdoc:
ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
	PYTHONPATH=$(CURDIR)/src python3 -m sphinx -b html -N docs/source $(CURDIR)/debian/python-docformatter-doc/usr/share/doc/python-docformatter-doc/html
	dh_sphinxdoc
endif
