# Copyright (C) 2011 Marie E. Rognes
#
# This file is part of FFC.
#
# FFC 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.
#
# FFC 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 FFC. If not, see <http://www.gnu.org/licenses/>.
#
# First added:  2011-11-16
# Last changed: 2011-11-16

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

echo ""
echo "--- Generating FFC 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 ffc --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__' ffc/__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 ""
