diff --git a/tools/build-rst.sh b/tools/build-rst.sh new file mode 100755 index 0000000000..3a9e7c77d3 --- /dev/null +++ b/tools/build-rst.sh @@ -0,0 +1,78 @@ +#!/bin/bash -xe +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +DIRECTORY=$1 + +if [ -z "$DIRECTORY" ] ; then + echo "usage $0 DIRECTORY options" + echo "Options are:" + echo "--glossary: Build glossary" + echo "--tag TAG: Use given tag for building" + echo "--target TARGET: Copy files to publish-docs/$TARGET" + echo "--build BUILD: Name of build directory" + exit 1 +fi + +GLOSSARY=0 +TARGET="" +TAG="" +TAG_OPT="" +BUILD="" + +while [[ $# > 1 ]] ; do + option="$1" + case $option in + --glossary) + GLOSSARY=1 + ;; + --tag) + TAG="$2" + TAG_OPT="-t $2" + shift + ;; + --target) + TARGET="$2" + shift + ;; + --build) + BUILD="$2" + shift + ;; + esac + shift +done + + +if [ "$GLOSSARY" -eq "1" ] ; then + echo "Generating Glossary" + tools/glossary2rst.py $DIRECTORY/source/glossary.rst +fi + +if [ -z "BUILD" ] ; then + if [ -z "$TAG" ] ; then + BUILD_DIR="$DIRECTORY/build/html" + else + BUILD_DIR="$DIRECTORY/build-${TAG}/html" + fi +else + BUILD_DIR="$DIRECTORY/$BUILD/html" +fi + +sphinx-build -E -W $TAG_OPT $DIRECTORY/source $BUILD_DIR + +# Copy RST +if [ "$TARGET" != "" ] ; then + mkdir -p publish-docs/$TARGET + rsync -a $BUILD_DIR publish-docs/$TARGET +fi diff --git a/tools/build-user-guides.sh b/tools/build-user-guides.sh index f552521922..1412fd461d 100755 --- a/tools/build-user-guides.sh +++ b/tools/build-user-guides.sh @@ -1,16 +1,8 @@ #!/bin/sh -e -echo "Generating Glossary" -echo "===================" -tools/glossary2rst.py doc/user-guides/source/glossary.rst -echo "Done." -echo "" -echo "Building End User Guide" -echo "=======================" -sphinx-build -t user_only -E -W doc/user-guides/source/ doc/user-guides/build/html -echo "Building Admin User Guide" -echo "=========================" -sphinx-build -t admin_only -E -W doc/user-guides/source/ doc/user-guides/build-admin/html +tools/build-rst.sh doc/user-guides --glossary --tag user_only --build build +# No need to build the glossary again here. +tools/build-rst.sh doc/user-guides --tag admin_only --build build-admin # Cleanup: Rename index-html to index everywhere mv doc/user-guides/build-admin/html/index-admin.html doc/user-guides/build-admin/html/index.html