#!/usr/bin/make -f

# Don't ship tests; unused (see below), useless in production, saves ~2MiB and
# they vary by locale (causing builds to not be reproducible).
export PYBUILD_AFTER_INSTALL = rm -rf {destdir}/{install_dir}/pelican/tests

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

override_dh_clean:
	dh_clean
	rm -rf pelican.egg-info build/html

override_dh_auto_build:
	dh_auto_build
	PYTHONPATH=. http_proxy='http://127.0.0.1:9/' python3 -m sphinx -N -E -bhtml docs build/html
	rm -rf build/html/.doctrees

override_dh_auto_test:
	@echo "Tests currently disabled!"

override_dh_installchangelogs:
	dh_installchangelogs docs/changelog.rst

override_dh_compress:
	dh_compress -Xchangelog.html

generate_manpages:
	# Generate manpages using help2man
	# Sanity check the resulting manfiles, some of the output may be broken
	[ -x /usr/bin/pelican ] && help2man -N --no-discard-stderr -n "tool to generate a static blog" /usr/bin/pelican > debian/pelican.1
	[ -x /usr/bin/pelican-import ] && help2man -N --no-discard-stderr -n "import from a feed, Wordpress, or Dotclear files" /usr/bin/pelican-import > debian/pelican-import.1
	[ -x /usr/bin/pelican-plugins ] && help2man -N --no-discard-stderr -n "manage Pelican plugins" /usr/bin/pelican-plugins > debian/pelican-plugins.1
	[ -x /usr/bin/pelican-quickstart ] && help2man -N --no-discard-stderr -n "kickstart a Pelican blog" /usr/bin/pelican-quickstart > debian/pelican-quickstart.1
	[ -x /usr/bin/pelican-themes ] && help2man -N --no-discard-stderr -n "install themes for Pelican" /usr/bin/pelican-themes > debian/pelican-themes.1
