#!/bin/sh
set -eu

# Run from the source root; keep all generated files in the build directory.
root=$(pwd)
website_build="$root/build/website"
mkdir -p "$website_build/doxygen"
sed -e "s|@DOXYGEN_INPUT_DIR@|$root/src/lib/OpenEXRCore|g" \
    -e "s|@DOXYGEN_OUTPUT_DIR@|$website_build/doxygen|g" \
    website/Doxyfile.in > "$website_build/Doxyfile"
doxygen "$website_build/Doxyfile"
READTHEDOCS=False sphinx-build -b html \
    -D html_theme=classic -D html_theme_options={} \
    -D "mathjax_path=file:///usr/share/javascript/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML" \
    -d "$website_build/doctrees" \
    -Dbreathe_projects.OpenEXR="$website_build/doxygen/xml" \
    website "$website_build/sphinx"
