Merge "PDF generation support with --pdf option"

This commit is contained in:
Jenkins 2016-12-09 08:11:24 +00:00 committed by Gerrit Code Review
commit c252531989
4 changed files with 46 additions and 7 deletions

View File

@ -19,3 +19,7 @@ python-lxml
xsltproc [platform:dpkg] xsltproc [platform:dpkg]
zlib-devel [platform:rpm] zlib-devel [platform:rpm]
zlib1g-dev [platform:dpkg] zlib1g-dev [platform:dpkg]
inkscape
texlive-latex-base [platform:dpkg]
texlive-latex-extra [platform:dpkg]
texlive-fonts-recommended [platform:dpkg]

View File

@ -9,18 +9,35 @@ if [[ $# > 0 ]] ; then
fi fi
fi fi
PDF_OPTION="--pdf"
# PDF targets for Install guides are dealt in build-install-guides-rst.sh
PDF_TARGETS=( 'arch-design' 'arch-design-draft' 'cli-reference'\
'ha-guide' 'networking-guide'\
'ops-guide' 'user-guide' )
for guide in admin-guide arch-design cli-reference contributor-guide \ for guide in admin-guide arch-design cli-reference contributor-guide \
ha-guide image-guide ops-guide user-guide; do ha-guide image-guide ops-guide user-guide; do
tools/build-rst.sh doc/$guide --build build \ if [[ ${PDF_TARGETS[*]} =~ $guide ]]; then
--target $guide $LINKCHECK tools/build-rst.sh doc/$guide --build build \
--target $guide $LINKCHECK $PDF_OPTION
else
tools/build-rst.sh doc/$guide --build build \
--target $guide $LINKCHECK
fi
done done
# Draft guides # Draft guides
# This includes guides that we publish from stable branches # This includes guides that we publish from stable branches
# as versioned like the networking-guide. # as versioned like the networking-guide.
for guide in networking-guide arch-design-draft config-reference; do for guide in networking-guide arch-design-draft config-reference; do
tools/build-rst.sh doc/$guide --build build \ if [[ ${PDF_TARGETS[*]} =~ $guide ]]; then
--target "draft/$guide" $LINKCHECK tools/build-rst.sh doc/$guide --build build \
--target "draft/$guide" $LINKCHECK $PDF_OPTION
else
tools/build-rst.sh doc/$guide --build build \
--target "draft/$guide" $LINKCHECK
fi
done done
tools/build-install-guides-rst.sh $LINKCHECK tools/build-install-guides-rst.sh $LINKCHECK

View File

@ -27,7 +27,7 @@ for tag in $TAGS; do
# Build the guide with debconf # Build the guide with debconf
# To use debian only contents, use "debian" tag. # To use debian only contents, use "debian" tag.
tools/build-rst.sh doc/install-guide-debconf \ tools/build-rst.sh doc/install-guide-debconf \
--tag debian --target "draft/install-guide-${tag}" $LINKCHECK --tag debian --target "draft/install-guide-${tag}" $LINKCHECK --pdf
else else
## ##
# Because Sphinx uses the first heading as title regardless of # Because Sphinx uses the first heading as title regardless of
@ -40,6 +40,6 @@ for tag in $TAGS; do
# Build the guide # Build the guide
tools/build-rst.sh doc/install-guide \ tools/build-rst.sh doc/install-guide \
--tag ${tag} --target "draft/install-guide-${tag}" $LINKCHECK --tag ${tag} --target "draft/install-guide-${tag}" $LINKCHECK --pdf
fi fi
done done

View File

@ -21,6 +21,7 @@ if [ -z "$DIRECTORY" ] ; then
echo "--target TARGET: Copy files to publish-docs/$TARGET" echo "--target TARGET: Copy files to publish-docs/$TARGET"
echo "--build BUILD: Name of build directory" echo "--build BUILD: Name of build directory"
echo "--linkcheck: Check validity of links instead of building" echo "--linkcheck: Check validity of links instead of building"
echo "--pdf: PDF file generation"
exit 1 exit 1
fi fi
@ -29,6 +30,7 @@ TAG=""
TAG_OPT="" TAG_OPT=""
BUILD="" BUILD=""
LINKCHECK="" LINKCHECK=""
PDF=""
while [[ $# > 0 ]] ; do while [[ $# > 0 ]] ; do
option="$1" option="$1"
@ -49,6 +51,9 @@ while [[ $# > 0 ]] ; do
TARGET="$2" TARGET="$2"
shift shift
;; ;;
--pdf)
PDF=1
;;
esac esac
shift shift
done done
@ -57,11 +62,14 @@ done
if [ -z "$BUILD" ] ; then if [ -z "$BUILD" ] ; then
if [ -z "$TAG" ] ; then if [ -z "$TAG" ] ; then
BUILD_DIR="$DIRECTORY/build/html" BUILD_DIR="$DIRECTORY/build/html"
BUILD_DIR_PDF="$DIRECTORY/build/pdf"
else else
BUILD_DIR="$DIRECTORY/build-${TAG}/html" BUILD_DIR="$DIRECTORY/build-${TAG}/html"
BUILD_DIR_PDF="$DIRECTORY/build-${TAG}/pdf"
fi fi
else else
BUILD_DIR="$DIRECTORY/$BUILD/html" BUILD_DIR="$DIRECTORY/$BUILD/html"
BUILD_DIR_PDF="$DIRECTORY/$BUILD/pdf"
fi fi
DOCTREES="${BUILD_DIR}.doctrees" DOCTREES="${BUILD_DIR}.doctrees"
@ -85,7 +93,17 @@ else
$TAG_OPT $DIRECTORY/source $BUILD_DIR $TAG_OPT $DIRECTORY/source $BUILD_DIR
set +x set +x
# Copy RST # PDF generation
if [ "$PDF" = "1" ] ; then
set -x
sphinx-build -E -W -d $DOCTREES -b latex \
$TAG_OPT $DIRECTORY/source $BUILD_DIR_PDF
make -C $BUILD_DIR_PDF
cp $BUILD_DIR_PDF/*.pdf $BUILD_DIR/
set +x
fi
# Copy RST (and PDF)
if [ "$TARGET" != "" ] ; then if [ "$TARGET" != "" ] ; then
mkdir -p publish-docs/$TARGET mkdir -p publish-docs/$TARGET
rsync -a $BUILD_DIR/ publish-docs/$TARGET/ rsync -a $BUILD_DIR/ publish-docs/$TARGET/