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

include /usr/share/dpkg/pkg-info.mk

export SETUPTOOLS_SCM_PRETEND_VERSION=${DEB_VERSION_UPSTREAM}
export HOME=$(CURDIR)
export PYBUILD_NAME=spopt
export PYBUILD_BEFORE_TEST=cp -r {dir}/spopt/tests/data {build_dir}/spopt/tests \

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

# Build sphinx HTML documentation
override_dh_auto_build:
	dh_auto_build
	PYTHONPATH=. \
		https_proxy='https://127.0.0.1:9/' \
		no_proxy=localhost python3 -m sphinx -N -bhtml -d \
		debian/doctrees docs/ debian/html

#override_dh_auto_test:

override_dh_link:
	dh_link
#Fixe duplicate-files
	jdupes -rl debian/python-spopt-doc/usr

#Fixe privacy-breach-generic
	find debian/python-spopt-doc/ -name '*.html' -exec sed -i 's|src="https://cdn||g' {} \;

#Fixe privacy-breach-logo
	find debian/python-spopt-doc/ -name '*.html' -exec sed -i 's|https://mybinder.org/badge_logo.svg||g' {} \;

#Fixe font-in-non-font-package
	find debian/python-spopt-doc/ -name '*glyphicons-*' -delete

#Fixe embedded-javascript-library
	find debian/python-spopt-doc/usr/share/doc -name '*.js' -delete
	find debian/python-spopt-doc/usr/share/doc -type d -empty -delete
