#! /bin/bash

# For URL structure reasons, our "api/" directory has a mixture of "root" files
# that must exist (the ones for each module) and other files that live in
# version control but are generated by the automodapi system. In order to
# refresh the latter files, they must be deleted before running a doc build.
# This script does that, while leaving the "root" files.

apidir=$(dirname $0)/api

cd "$apidir"

for f in *.rst; do
    case "$f" in
    toasty.rst|\
    toasty.builder.rst|\
    toasty.cli.rst|\
    toasty.collection.rst|\
    toasty.fits_tiler.rst|\
    toasty.image.rst|\
    toasty.merge.rst|\
    toasty.multi_tan.rst|\
    toasty.openexr.rst|\
    toasty.par_util.rst|\
    toasty.pipeline.rst|\
    toasty.pipeline.astropix.rst|\
    toasty.pipeline.azure_io.rst|\
    toasty.pipeline.cli.rst|\
    toasty.pipeline.djangoplicity.rst|\
    toasty.pipeline.local_io.rst|\
    toasty.progress.rst|\
    toasty.pyramid.rst|\
    toasty.samplers.rst|\
    toasty.study.rst|\
    toasty.toast.rst) ;;

    *) rm -f "$f"
    esac
done
