#!/usr/bin/make -f
#export DH_VERBOSE = 1
export PYBUILD_NAME=pyfunceble
PACKAGE = python3-pyfunceble

# Tests disabled due to trying to connect to an external network
export PYBUILD_DISABLE=test

%:
	dh $@ --buildsystem=pybuild

override_dh_auto_build:
	dh_auto_build
ifeq ($(filter nodoc,$(DEB_BUILD_OPTIONS)),)
	python3 $(CURDIR)/docs/gen_ref_pages.py
	mkdocs build -d $(CURDIR)/debian/html -f $(CURDIR)/mkdocs.yml
endif

# Fixed lintian python-pyfunceble-doc: privacy-breach-generic
override_dh_installdocs:
	dh_installdocs
	find debian/python-pyfunceble-doc/ -type f -name sitemap.xml.gz -delete
	find debian/python-pyfunceble-doc/ -name '*.html' -exec sed -i \
		-e '/https:\/\/asciinema.org/d' \
		-e '/https:\/\/fonts.googleapis.com\//d' \
		-e '/https:\/\/fonts.gstatic.com/d' \
		-e '/https:\/\/unpkg.com\/iframe-worker\/shim/d' \
		-e 's/<img [^>]*>//g' {} \;

override_dh_mkdocs:
	dh_mkdocs --theme-package mkdocs-material

# Upstream informs that such tools are intended for developers only. Unnecessary for user use.
# https://github.com/funilrys/PyFunceble/commit/3a61b8424bafa17b1879e94e90ae3e0ad972be41
execute_after_dh_install:
	rm -f debian/$(PACKAGE)/usr/bin/PyFunceble
	rm -f debian/$(PACKAGE)/usr/bin/clean-pyfunceble

override_dh_installexamples:
	dh_installexamples examples/api_usage examples/lists
