#!/usr/bin/make -f
#export DH_VERBOSE = 1

export PYBUILD_NAME=mkdocs-rss-plugin
export PYBUILD_DESTDIR=debian/mkdocs-rss-plugin

# Tests ignored due to missing dependencies or incompatibilities in Debian:
# - test_rss_util: requires 'validator_collection' (not packaged in Debian)
# - test_build/test_build_no_git/test_no_material: require 'jsonfeed' (not packaged in Debian)
# - test_integrations_material*: require 'materialx' theme (not available in Debian's mkdocs-material)
# - test_plugin_config_through_mkdocs: uses 'materialx' theme fixture, incompatible with Debian
export PYBUILD_TEST_ARGS=-v --no-cov \
			    --ignore=tests/test_rss_util.py \
			    --ignore=tests/test_build.py \
			    --ignore=tests/test_build_no_git.py \
			    --ignore=tests/test_integrations_material.py \
			    --ignore=tests/test_integrations_material_blog.py \
			    --ignore=tests/test_integrations_material_social_cards.py \
			    --ignore=tests/test_no_material.py \
			    -k "not test_plugin_config_through_mkdocs"
%:
	dh $@ --buildsystem=pybuild

override_dh_auto_build:
	dh_auto_build
ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
	PYTHONPATH=. 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-rss-plugin-doc/usr/share/doc/mkdocs-rss-plugin/* \
	   $(CURDIR)/debian/mkdocs-rss-plugin-doc/usr/share/doc/mkdocs-rss-plugin-doc && \
	rm -rf $(CURDIR)/debian/mkdocs-rss-plugin-doc/usr/share/doc/mkdocs-rss-plugin
	find debian/mkdocs-rss-plugin-doc/ -type f -name sitemap.xml.gz -delete
endif

override_dh_auto_install:
	dh_auto_install
	find debian -type d -name junit -exec rm -rf {} + 2>/dev/null
