#!/usr/bin/make -f

%:
	dh $@ --buildsystem=pybuild

execute_after_dh_clean:
	rm -f xsdata*.1

execute_after_dh_auto_build:
ifeq ($(filter nodoc,$(DEB_BUILD_OPTIONS)),)
	PYTHONPATH=$(shell pybuild --print build_dir --interpreter python3) \
	  PATH=$(shell pybuild --print build_dir --interpreter python3)/../scripts:$$PATH \
	  mkdocs build --no-directory-urls -d build/html
	# strip Google Fonts and point to a local copy instead
	cp /usr/share/fonts-roboto-fontface/css/roboto/roboto-fontface.css build/html/assets/stylesheets/
	find build/html -type f -name "*.html" -exec \
	  sed -i \
	    -e '\,link rel="preconnect" href="https://fonts.*,d' \
	    -e 's,href="https://fonts.googleapis.com/css?family=Roboto[^"]*",href="../assets/stylesheets/roboto-fontface.css",' \
	{} \;
endif

override_dh_mkdocs:
	dh_mkdocs -T mkdocs-material -T fonts-roboto-fontface

execute_before_dh_installman:
	PYTHONPATH=$$(pybuild --print build_dir |awk '{print $$3}') python3 -m click_man --target $(CURDIR) xsdata
