#!/bin/bash
set -ex

rm -rf ../docs
python3 docex_contour.py
python3 docex_tutorial.py

# Render terminal GIFs
# Note this does not seem to work on GitHub Action runners so we have to manually
# commit these gifs whenever we think they should change. faressoft/terminalizer#127
npx terminalizer@0.9.0 render cxroots_progress -o ../docs_src/cxroots_progress.gif
npx terminalizer@0.9.0 render cxroots_logging_progress -o ../docs_src/cxroots_logging_progress.gif

# Build documentation
sphinx-build -b html . ../docs -T -E -a -W

# Clean up
find *.gif *.png \
    ! -name 'cxroots_progress.gif' \
    ! -name 'cxroots_logging_progress.gif' \
    -delete
