Browse Source

Factor out Install Guide for Debian with debconf

Sync install guide translation build tool with the
changes I8df6b3b382137d08d60f85bc41bcd98ac1f4eb47
and Iffced3907ac2fddd42e6adc56b6e4859fde8e987.

Change-Id: Ie3d20ab930738925f2daacd4cd305b4ad8ec1798
changes/80/322380/1
KATO Tomoyuki 5 years ago
parent
commit
8b9a52f570
1 changed files with 39 additions and 54 deletions
  1. +39
    -54
      bin/doc-tools-check-languages

+ 39
- 54
bin/doc-tools-check-languages View File

@ -102,7 +102,7 @@ function build_rst {
done
elif [ ${book} = "install-guide" ] ; then
# Install Guide has several variations, build all of them
TAGS="obs rdo ubuntu"
TAGS="obs rdo ubuntu debian debconf"
INDEX=${DOC_DIR}${book}/source/index.rst
# For translation work, we should have only one index file,
@ -116,60 +116,45 @@ function build_rst {
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}/" ${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}
if [[ "$tag" == "debconf" ]]; then
# Build the guide with debconf
# To use debian only contents, use "debian" tag.
BUILD_DIR="${DOC_DIR}${book}-${tag}/build-${tag}/html"
DOCTREES="${BUILD_DIR}.doctrees"
tox -evenv "sphinx-build -q -E -t debian \
-D language=${language}
-d ${DOCTREES}
${DOC_DIR}${book}-${tag}/source/ \
${BUILD_DIR}"
mkdir -p publish-docs/${language}/${book}-${tag}
rsync -a ${DOC_DIR}${book}-${tag}/build-${tag}/html/ \
publish-docs/${language}/${book}-${tag}
else
sed -i "${lineno_debian},$((${lineno_end}-1))d" ${INDEX}
sed -i "${lineno_notdebian}d" ${INDEX}
fi
# Build the guide
BUILD_DIR="${DOC_DIR}${book}/build-${tag}/html"
DOCTREES="${BUILD_DIR}.doctrees"
tox -evenv "sphinx-build -q -E -t $tag \
-D language=${language}
-d ${DOCTREES}
${DOC_DIR}${book}/source/ \
${BUILD_DIR}"
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
##
# 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}/" ${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.
# Build the guide
BUILD_DIR="${DOC_DIR}${book}/build-${tag}/html"
DOCTREES="${BUILD_DIR}.doctrees"
tox -evenv "sphinx-build -q -E -t $tag \
-D language=${language}
-d ${DOCTREES}
${DOC_DIR}${book}/source/ \
${BUILD_DIR}"
mkdir -p publish-docs/${language}/${book}-${tag}
rsync -a ${DOC_DIR}${book}/build-${tag}/html/ \
publish-docs/${language}/${book}-${tag}
fi
done
else


Loading…
Cancel
Save