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

#export DH_VERBOSE = 1

SPHINXOPTS := -N -E

export PYBUILD_AFTER_BUILD := \
	PYTHONPATH={home_dir} python3 -m sphinx -b html $(SPHINXOPTS) docs/ build/html; \
	PYTHONPATH={home_dir} python3 -m sphinx -b man $(SPHINXOPTS) docs/ build/man; \
	cp debian/external-graphics/directive.gif build/html

%:
	dh $@ --buildsystem=pybuild

override_dh_clean:
	dh_clean
	rm -rf .mypy_cache
	rm -f docs/index.md

override_dh_sphinxdoc:
	dh_sphinxdoc
	for file in `find $(CURDIR)/debian/python3-sphinxcontrib-mermaid/usr/share/doc/python3-sphinxcontrib-mermaid/html -type f -name "*.html"`; do \
	    sed -i "s/https:\/\/cdn\.jsdelivr\.net\/npm\/d3@7.9.0\/dist/file:\/\/\/usr\/share\/javascript\/d3/g" $${file} ;\
	done
