#!/bin/sh

set -e -u

if [ $# -eq 0 ]
then
    printf 'Usage: %s <target-directory>\n' "$0" >&2
    exit 1
fi

here="$(dirname "$0")"
rm -rf "$here/tmp/"
./sphinx-build.py -b html "$here" "$here/tmp"
find sphinx/themes/ -type f -name '*.js' ! -name websupport.js \
| xargs -t -I '{}' cp -f '{}' "$1"
( cd "$here/tmp/_static" && rm jquery.js underscore.js websupport.js )
find "$here/tmp/_static/" -name '*.js' \
| xargs -t -I '{}' cp -f '{}' "$1"
rm -rf "$here/tmp/"

# vim:ts=4 sw=4 et
