From 3330718f4bd971329c24847241cb13dabe4649de Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Sun, 12 Jul 2015 11:53:51 +0200 Subject: [PATCH] Rework RST building Use the same shell scripts like openstack-manuals for building of RST files. This simplifies the tox.ini file and allows easier adding of new tags. This now build dotnet, fog, and pkgcloud versions as draft documents and continues to publish the libcloud version. Change-Id: Id5deebbb54904a44691104e19ef60f15a14c0f7c --- tools/build-all-rst.sh | 5 +++ tools/build-firstapp-rst.sh | 15 +++++++ tools/build-rst.sh | 78 +++++++++++++++++++++++++++++++++++++ tox.ini | 23 +++-------- 4 files changed, 104 insertions(+), 17 deletions(-) create mode 100755 tools/build-all-rst.sh create mode 100755 tools/build-firstapp-rst.sh create mode 100755 tools/build-rst.sh diff --git a/tools/build-all-rst.sh b/tools/build-all-rst.sh new file mode 100755 index 000000000..4bc7e2c68 --- /dev/null +++ b/tools/build-all-rst.sh @@ -0,0 +1,5 @@ +#!/bin/bash -e + +mkdir -p publish-docs + +tools/build-firstapp-rst.sh diff --git a/tools/build-firstapp-rst.sh b/tools/build-firstapp-rst.sh new file mode 100755 index 000000000..401380bec --- /dev/null +++ b/tools/build-firstapp-rst.sh @@ -0,0 +1,15 @@ +#!/bin/bash -e + +mkdir -p publish-docs + +# Publish documents to api-ref for developer.openstack.org +for tag in libcloud; do + tools/build-rst.sh firstapp \ + --tag ${tag} --target "api-ref/firstapp-${tag}" +done + +# Draft documents +for tag in dotnet fog pkgcloud; do + tools/build-rst.sh firstapp \ + --tag ${tag} --target "draft/firstapp-${tag}" +done diff --git a/tools/build-rst.sh b/tools/build-rst.sh new file mode 100755 index 000000000..c4b838301 --- /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 doc/common-rst/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/tox.ini b/tox.ini index 3046e972c..7b51b5473 100644 --- a/tox.ini +++ b/tox.ini @@ -37,16 +37,7 @@ commands = openstack-doc-test --check-deletions {posargs} [testenv:checkbuild] commands = # Build and copy RST Guides - # Include only environments that are (partially) written - # TODO(ajaeger): We publish to content to allow for reviewing, this needs a - # change of openstack-doc-tools to remove content here in the file layout - # for previewing. - sphinx-build -E -W -t libcloud firstapp/source firstapp/build-libcloud/html - mkdir -p publish-docs/firstapp-libcloud/content - rsync -a firstapp/build-libcloud/html/ publish-docs/firstapp-libcloud/content/ - sphinx-build -E -W -t fog firstapp/source firstapp/build-fog/html - mkdir -p publish-docs/firstapp-fog/content - rsync -a firstapp/build-fog/html/ publish-docs/firstapp-fog/content/ + {toxinidir}/tools/build-all-rst.sh # Build DocBook Guides openstack-doc-test --check-build {posargs} @@ -63,10 +54,10 @@ commands = openstack-doc-test --check-build --publish --only-book api-ref --only-book api-ref-guides # We need to move api-ref-guides to the proper place: mv publish-docs/api-ref-guides publish-docs/api-ref/ - # We need to move firstapp-libcloud to the proper place: - sphinx-build -E -W -t libcloud firstapp/source firstapp/build-libcloud/html - mkdir -p publish-docs/api-ref/firstapp-libcloud/ - rsync -a firstapp/build-libcloud/html/ publish-docs/api-ref/firstapp-libcloud/ + # Build and copy RST Guides + {toxinidir}/tools/build-all-rst.sh + # Delete firstapp draft documents + rm -rf publish-docs/draft/ [testenv:checklang] # openstack-generate-docbook needs xml2po which cannot be installed in @@ -95,9 +86,7 @@ commands = doc-tools-check-languages doc-tools-check-languages.conf publish all [testenv:docs] commands = - # Include only environments that are (partially) written - sphinx-build -E -W -t libcloud firstapp/source firstapp/build-libcloud/html - sphinx-build -E -W -t fog firstapp/source firstapp/build-fog/html + {toxinidir}/tools/build-all-rst.sh [testenv:firstapp-libcloud] commands = sphinx-build -E -W -t libcloud firstapp/source firstapp/build-libcloud/html