Simplify RST building

Use a script to build and copy RST guides around instead of duplicating
the same lines every time.

Use script in build-user-guides.sh for now. A follow-up patch shall
change further places.

This script will eventually be moved over to openstack-doc-tools, let's
first evolve it here and check that we cover all use cases.

Change-Id: I753e742bf77b2d6f5acf2f909d62af3dd422832a
This commit is contained in:
Andreas Jaeger 2015-05-10 09:04:07 +02:00
parent b9fe165716
commit 94961a3c3a
2 changed files with 81 additions and 11 deletions

78
tools/build-rst.sh Executable file
View File

@ -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

View File

@ -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