#!/usr/bin/make -f
#export DH_VERBOSE = 1
export PYBUILD_NAME=mkdocs-print-site-plugin
export PYBUILD_DESTDIR=debian/mkdocs-print-site-plugin

export PYBUILD_TEST_ARGS=-v -k "not test_windmill"

%:
	dh $@ --buildsystem=pybuild


override_dh_clean:
	rm -rf html .pytest_cache
	dh_clean

override_dh_auto_build:
	dh_auto_build
ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
	mkdocs build -d $(CURDIR)/debian/html -f $(CURDIR)/mkdocs.yml
endif

override_dh_mkdocs:
ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
	dh_mkdocs
endif

override_dh_installdocs:
	dh_installdocs
ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
	# Workaround to move content into the correct -doc package directory
	mv $(CURDIR)/debian/mkdocs-print-site-plugin-doc/usr/share/doc/mkdocs-print-site-plugin/* \
	   $(CURDIR)/debian/mkdocs-print-site-plugin-doc/usr/share/doc/mkdocs-print-site-plugin-doc && \
	rm -rf $(CURDIR)/debian/mkdocs-print-site-plugin-doc/usr/share/doc/mkdocs-print-site-plugin
	find debian/mkdocs-print-site-plugin-doc/ -type f -name sitemap.xml.gz -delete
endif
