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

# Typer versions greater than 0.5.0 run tests that are influenced by the
# python3-rich dependency. This library respects some standard environment
# variables such as COLUMNS, but this variable can break tests that perform
# string comparisons if the terminal width is small. Upstream handles this by
# running tests with a large terminal width, since typer can override the
# terminal width by setting the variable below.
export TERMINAL_WIDTH=3000

export PYBUILD_NAME=typer

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

override_dh_auto_build:
	dh_auto_build
	mkdocs build --clean -d $(CURDIR)/html -f $(CURDIR)/mkdocs.yml
	rm -f $(CURDIR)/html/404.html \
	$(CURDIR)/html/sitemap.xml.gz

override_dh_auto_test:
	PYBUILD_SYSTEM=custom \
	PYBUILD_TEST_ARGS="pytest-3 --cov=typer --cov=tests --cov=docs_src --cov-report=term-missing -o console_output_style=progress --numprocesses=auto" \
	dh_auto_test

ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
override_dh_installdocs:
	dh_installdocs
	dh_mkdocs -Tmkdocs -Treadthedocs -Tlibjs-underscore -Tnode-jquery
endif
