#!/usr/bin/env bash

set -euo pipefail

runfiles=${BASH_SOURCE[0]}.runfiles

doxyfile="$1"
doc_dir="$2"
doc_path="$3"
tar_output="$4"

# clean up any previous generated doc files
rm -rf "$tar_output" "$doc_dir/$doc_path"

py_filter=$runfiles/zoox/doc/doxygen/py_filter
export PATH=$(dirname $py_filter):$PATH
export PYTHONPATH=$runfiles/pypi__doxypypy_python3_deps:${PYTHONPATH:-}

$runfiles/doxygen/doxygen "$doxyfile"
tar -czf "$tar_output" --directory "$doc_dir" "$doc_path"
