#!/bin/sh

if [ "$1" = "publish" ] ; then
    PUBLISH=1
    OPS="-D live_site=1"
    shift;
fi

mkdir -p docs/_static docs/_build
sphinx-build $OPS "$@" -E -b html docs/ docs/_build || exit 1
if [ "$PUBLISH" = "1" ] ; then
  cd docs/_build
  echo "Uploading files..."
  tar czvf - . | ssh flow.openplans.org 'ssh acura.openplans.org "cd /www/deliverance.openplans.org/; tar xzvf -"'
fi
