#!/usr/bin/env bash
#
# Generate the Doxygen HTML documentation in $DOXYGENTARGET.
#
# The shipped Doxyfile keeps all documentation settings. Only the output
# location is overridden here, because Doxygen has no command line option for
# setting configuration values.
#
set -euo pipefail

target=${DOXYGENTARGET:-html}
mkdir -p "$target"

config=$(mktemp "${TMPDIR:-/tmp}/kaskade7-doxyfile.XXXXXX")
trap 'rm -f "$config"' EXIT

sed -e "s|^OUTPUT_DIRECTORY[[:space:]]*=.*|OUTPUT_DIRECTORY = $target|" \
    -e "s|^HTML_OUTPUT[[:space:]]*=.*|HTML_OUTPUT = .|" \
    Doxyfile > "$config"

echo "doxygen: writing HTML documentation to $target"
doxygen "$config"
