Rework install guide translation build tool
Sync translation build tool with Change-Id: I3abcd7da3569bb8e9edbc02574dcb74c12752ede. Change-Id: I45f66ba19d0946175dbace95082454bdd1187bf1 Closes-Bug: #1516079
This commit is contained in:
parent
926a7413ba
commit
9abcfea69c
@ -97,31 +97,70 @@ function build_rst {
|
||||
done
|
||||
elif [ ${book} = "install-guide" ] ; then
|
||||
# Install Guide has several variations, build all of them
|
||||
title_org=$(grep "title::" ${DOC_DIR}${book}/source/index.rst | \
|
||||
awk '{print substr($0, index($0, "::")+3)}')
|
||||
TAGS="obs rdo ubuntu debian"
|
||||
INDEX=${DOC_DIR}${book}/source/index.rst
|
||||
|
||||
trap "sed -i -e \"s/\.\. title::.*/.. title:: ${title_org}/\" \
|
||||
${DOC_DIR}${book}/source/index.rst" EXIT
|
||||
# For translation work, we should have only one index file,
|
||||
# because our tools generate translation resources from
|
||||
# only one index file.
|
||||
# Therefore, this tool uses one combined index file
|
||||
# while processing title and toctree for each distribution.
|
||||
|
||||
for tag in obs rdo ubuntu debian; do
|
||||
title=$(grep -m 1 -A 5 ".. only:: ${tag}" \
|
||||
${DOC_DIR}${book}/source/index.rst | \
|
||||
# Save and restore the index file
|
||||
cp -f ${INDEX} ${INDEX}.save
|
||||
trap "mv -f ${INDEX}.save ${INDEX}" EXIT
|
||||
|
||||
for tag in $TAGS; do
|
||||
##
|
||||
# Because Sphinx uses the first heading as title regardless of
|
||||
# only directive, replace title directive with the proper title
|
||||
# for each distribution to set the title explicitly.
|
||||
title=$(grep -m 1 -A 5 "^.. only:: ${tag}" ${INDEX} | \
|
||||
sed -n 4p | sed -e 's/^ *//g')
|
||||
sed -i -e "s/\.\. title::.*/.. title:: ${title}/" \
|
||||
${DOC_DIR}${book}/source/index.rst
|
||||
tox -evenv "sphinx-build -j $NUMBER_OF_CORES -q -E -t $tag -D language=${language} \
|
||||
${DOC_DIR}${book}/source/ \
|
||||
sed -i -e "s/\.\. title::.*/.. title:: ${title}/" ${INDEX}
|
||||
|
||||
##
|
||||
# Sphinx builds the navigation before processing directives,
|
||||
# so the conditional toctree does not work.
|
||||
# We need to prepare toctree depending on distribution
|
||||
# only with one toctree before exectuing sphinx-build.
|
||||
|
||||
# Get line number of each tag
|
||||
lineno_start=$(grep -n "^Contents" ${INDEX} | sed -e 's/:.*//')
|
||||
lineno_end=$(grep -n "^.. end of contents" ${INDEX} | sed -e 's/:.*//')
|
||||
lineno_debian=$(grep -n "^.. only:: debian" ${INDEX} \
|
||||
| tail -1 | sed -e 's/:.*//')
|
||||
lineno_notdebian=$(grep -n "^.. only:: [^d]" ${INDEX} \
|
||||
| tail -1 | sed -e 's/:.*//')
|
||||
|
||||
# Remove indent for pseudo only directive
|
||||
sed -i "${lineno_start},${lineno_end} s/^ *\.\. toctree/.. toctree/" ${INDEX}
|
||||
sed -i "${lineno_start},${lineno_end} s/^ */ /" ${INDEX}
|
||||
|
||||
# Remove unnecessary toctree for each distribution
|
||||
if [[ "$tag" == "debian" ]]; then
|
||||
sed -i "${lineno_notdebian},${lineno_debian}d" ${INDEX}
|
||||
else
|
||||
sed -i "${lineno_debian},$((${lineno_end}-1))d" ${INDEX}
|
||||
sed -i "${lineno_notdebian}d" ${INDEX}
|
||||
fi
|
||||
|
||||
# Build the guide
|
||||
tox -evenv "sphinx-build -j $NUMBER_OF_CORES -q -E -t $tag \
|
||||
-D language=${language} ${DOC_DIR}${book}/source/ \
|
||||
${DOC_DIR}${book}/build-${tag}/html"
|
||||
mkdir -p publish-docs/${language}/${book}-${tag}
|
||||
rsync -a ${DOC_DIR}${book}/build-${tag}/html/ \
|
||||
publish-docs/${language}/${book}-${tag}
|
||||
|
||||
# Restore the index file
|
||||
cp -f ${INDEX}.save ${INDEX}
|
||||
|
||||
# Remove Debian specific content from other guides
|
||||
if [[ "$tag" != "debian" ]]; then
|
||||
rm -rf publish-docs/${language}/{book}-$tag/debconf
|
||||
fi
|
||||
done
|
||||
# Debian Install Guide uses index-debian, we need to rename the file
|
||||
INSTALL_DEBIAN="publish-docs/${language}/install-guide-debian/"
|
||||
if [ -f ${INSTALL_DEBIAN}/index-debian.html ] ; then
|
||||
mv ${INSTALL_DEBIAN}/index-debian.html \
|
||||
${INSTALL_DEBIAN}/index.html
|
||||
fi
|
||||
else
|
||||
tox -evenv "sphinx-build -j $NUMBER_OF_CORES -q -E -D language=${language} \
|
||||
${DOC_DIR}${book}/source/ \
|
||||
|
@ -0,0 +1,4 @@
|
||||
---
|
||||
fixes:
|
||||
- Rework install guide translation build tool
|
||||
to process toctree for each distribution dynamically.
|
Loading…
Reference in New Issue
Block a user