#!/usr/bin/make -f

#export DH_VERBOSE = 1
export HOME=$(CURDIR)
export PYBUILD_TEST_ARGS={dir}/tests/tests.py
export PYBUILD_NAME=flask-paginate
export DOC_PKG := python-flask-paginate-doc
export DOC_PKG_PATH := $(CURDIR)/debian/$(DOC_PKG)

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

 # Build sphinx HTML documentation
 override_dh_sphinxdoc:
 ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
	PYTHONPATH=flask_paginate python3 -m sphinx -b html -d debian/doctrees \
		-N docs/ $(DOC_PKG_PATH)/usr/share/doc/$(DOC_PKG)/html
 endif

override_dh_link:
	dh_link
# Fix duplicate-files
	jdupes -rl debian/python-flask-paginate-doc/usr/share/doc/
	rm -rf debian/doctree

# Fix privacy-breach-generic
	find debian/python-flask-paginate-doc/ -name '*.html' \
		-exec sed -i 's|http://s3.amazonaws||g' {} \;

# Fix embedded-javascript-library
	find debian/python-flask-paginate-doc/usr/share/doc -name '*.js' -delete
