# Copyright (C) 2011 Marie E. Rognes
#
# This file is part of UFL.
#
# UFL is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# UFL is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with UFL. If not, see <http://www.gnu.org/licenses/>.
#
# First added:  2011-06-09
# Last changed: 2011-06-27

#
# This is a utility script for generating .rst and .html
# documentation for UFL.
#
# Run from the top level UFL directory:
#
#    ./scripts/makedoc
#

echo ""
echo "--- Generating UFL html documentation"
echo ""

SPHINX_DIR=./doc/sphinx
SPHINX_SCRIPT_DIR=$SPHINX_DIR/scripts
SPHINX_SOURCE_DIR=$SPHINX_DIR/source

# Generate .rst files
$SPHINX_SCRIPT_DIR/generate_modules.py ufl --dest-dir=$SPHINX_SOURCE_DIR --suffix=rst --force

echo ""
echo "--- reSTructured text files generated in doc/sphinx/source/"
echo ""

# Generate index (and add some labels)
VERSION=`grep '__version__' ufl/__init__.py | cut -d'"' -f2`
$SPHINX_SCRIPT_DIR/generate_index.py $SPHINX_SOURCE_DIR $VERSION

# Run sphinx make html
cd $SPHINX_DIR
make clean
make html

echo ""
echo "--- HTML files generated in $SPHINX_DIR/build/html"
echo ""
