Address pep8 warning at doc-tools-check-languages
Change-Id: Ifa6ae3657af2c55622b1d292b6451386403857b9
This commit is contained in:
parent
80a0206e8a
commit
4403ef6367
|
@ -57,31 +57,34 @@ function build_rst {
|
||||||
if [ ${book} = "install-guide" ] ; then
|
if [ ${book} = "install-guide" ] ; then
|
||||||
TAG="-t obs -t rdo -t ubuntu -t debian"
|
TAG="-t obs -t rdo -t ubuntu -t debian"
|
||||||
fi
|
fi
|
||||||
tox -evenv "sphinx-build -j $NUMBER_OF_CORES -q -E -W -b gettext $TAG ${DOC_DIR}${book}/source/ \
|
LOCALE_DIR="${DOC_DIR}${book}/source/locale/"
|
||||||
${DOC_DIR}${book}/source/locale/"
|
COMMON_DIR="${DOC_DIR}common-rst/source/locale/"
|
||||||
|
tox -evenv "sphinx-build -j $NUMBER_OF_CORES -q -E -W -b gettext $TAG \
|
||||||
|
${DOC_DIR}${book}/source/ ${LOCALE_DIR}"
|
||||||
|
|
||||||
# Merge the common-rst po file in
|
# Merge the common-rst po file in
|
||||||
if [[ -e ${DOC_DIR}common-rst/source/locale/${language}/LC_MESSAGES/common-rst.po ]] ; then
|
if [[ -e ${COMMON_DIR}${language}/LC_MESSAGES/common-rst.po ]] ; then
|
||||||
msgcat --use-first -o ${DOC_DIR}${book}/source/locale/${language}/${book}.po \
|
msgcat --use-first -o ${LOCALE_DIR}${language}/${book}.po \
|
||||||
${DOC_DIR}${book}/source/locale/${language}/LC_MESSAGES/${book}.po \
|
${LOCALE_DIR}${language}/LC_MESSAGES/${book}.po \
|
||||||
${DOC_DIR}common-rst/source/locale/${language}/LC_MESSAGES/common-rst.po
|
${COMMON_DIR}${language}/LC_MESSAGES/common-rst.po
|
||||||
mv -f ${DOC_DIR}${book}/source/locale/${language}/${book}.po \
|
mv -f ${LOCALE_DIR}${language}/${book}.po \
|
||||||
${DOC_DIR}${book}/source/locale/${language}/LC_MESSAGES/${book}.po
|
${LOCALE_DIR}${language}/LC_MESSAGES/${book}.po
|
||||||
fi
|
fi
|
||||||
# Now run msgmerge on all files
|
# Now run msgmerge on all files
|
||||||
for f in ${DOC_DIR}${book}/source/locale/*.pot ; do
|
for f in ${LOCALE_DIR}*.pot ; do
|
||||||
# Skip the master file
|
# Skip the master file
|
||||||
if [ $f = "${DOC_DIR}${book}/source/locale/${book}.pot" ] ; then
|
if [ $f = "${LOCALE_DIR}${book}.pot" ] ; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
bf=$(basename $f)
|
bf=$(basename $f)
|
||||||
# Remove .pot
|
# Remove .pot
|
||||||
bfname=${bf%.pot}
|
bfname=${bf%.pot}
|
||||||
msgmerge --silent -o ${DOC_DIR}${book}/source/locale/${language}/LC_MESSAGES/${bfname}.po \
|
msgmerge --silent \
|
||||||
${DOC_DIR}${book}/source/locale/${language}/LC_MESSAGES/${book}.po \
|
-o ${LOCALE_DIR}${language}/LC_MESSAGES/${bfname}.po \
|
||||||
${DOC_DIR}${book}/source/locale/${bf}
|
${LOCALE_DIR}${language}/LC_MESSAGES/${book}.po \
|
||||||
msgfmt ${DOC_DIR}${book}/source/locale/${language}/LC_MESSAGES/${bfname}.po \
|
${LOCALE_DIR}${bf}
|
||||||
-o ${DOC_DIR}${book}/source/locale/${language}/LC_MESSAGES/${bfname}.mo
|
msgfmt ${LOCALE_DIR}${language}/LC_MESSAGES/${bfname}.po \
|
||||||
|
-o ${LOCALE_DIR}${language}/LC_MESSAGES/${bfname}.mo
|
||||||
done
|
done
|
||||||
|
|
||||||
# Set the bug project to I18n project
|
# Set the bug project to I18n project
|
||||||
|
@ -94,7 +97,8 @@ function build_rst {
|
||||||
else
|
else
|
||||||
# Add the "bug_project" html context
|
# Add the "bug_project" html context
|
||||||
sed -i -e \
|
sed -i -e \
|
||||||
's/html_context *= *{/html_context = {"bug_project": "openstack-i18n", /' \
|
's/html_context *= *{/html_context = { \
|
||||||
|
"bug_project": "openstack-i18n", /' \
|
||||||
${DOC_DIR}${book}/source/conf.py
|
${DOC_DIR}${book}/source/conf.py
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -104,7 +108,8 @@ function build_rst {
|
||||||
for tag in libcloud dotnet fog openstacksdk pkgcloud shade; do
|
for tag in libcloud dotnet fog openstacksdk pkgcloud shade; do
|
||||||
BUILD_DIR="${DOC_DIR}${book}/build-${tag}/html"
|
BUILD_DIR="${DOC_DIR}${book}/build-${tag}/html"
|
||||||
DOCTREES="${BUILD_DIR}.doctrees"
|
DOCTREES="${BUILD_DIR}.doctrees"
|
||||||
tox -evenv "sphinx-build -j $NUMBER_OF_CORES -q -E -t $tag -D language=${language} \
|
tox -evenv "sphinx-build -j $NUMBER_OF_CORES -q -E \
|
||||||
|
-t $tag -D language=${language} \
|
||||||
-d ${DOCTREES}
|
-d ${DOCTREES}
|
||||||
${DOC_DIR}${book}/source/ \
|
${DOC_DIR}${book}/source/ \
|
||||||
${BUILD_DIR}"
|
${BUILD_DIR}"
|
||||||
|
@ -144,14 +149,16 @@ function build_rst {
|
||||||
|
|
||||||
# Get line number of each tag
|
# Get line number of each tag
|
||||||
lineno_start=$(grep -n "^Contents" ${INDEX} | sed -e 's/:.*//')
|
lineno_start=$(grep -n "^Contents" ${INDEX} | sed -e 's/:.*//')
|
||||||
lineno_end=$(grep -n "^.. end of contents" ${INDEX} | sed -e 's/:.*//')
|
lineno_end=$(grep -n "^.. end of contents" ${INDEX} \
|
||||||
|
| sed -e 's/:.*//')
|
||||||
lineno_debian=$(grep -n "^.. only:: debian" ${INDEX} \
|
lineno_debian=$(grep -n "^.. only:: debian" ${INDEX} \
|
||||||
| tail -1 | sed -e 's/:.*//')
|
| tail -1 | sed -e 's/:.*//')
|
||||||
lineno_notdebian=$(grep -n "^.. only:: [^d]" ${INDEX} \
|
lineno_notdebian=$(grep -n "^.. only:: [^d]" ${INDEX} \
|
||||||
| tail -1 | sed -e 's/:.*//')
|
| tail -1 | sed -e 's/:.*//')
|
||||||
|
|
||||||
# Remove indent for pseudo only directive
|
# Remove indent for pseudo only directive
|
||||||
sed -i "${lineno_start},${lineno_end} s/^ *\.\. toctree/.. toctree/" ${INDEX}
|
sed -i "${lineno_start},${lineno_end} \
|
||||||
|
s/^ *\.\. toctree/.. toctree/" ${INDEX}
|
||||||
sed -i "${lineno_start},${lineno_end} s/^ */ /" ${INDEX}
|
sed -i "${lineno_start},${lineno_end} s/^ */ /" ${INDEX}
|
||||||
|
|
||||||
# Remove unnecessary toctree for each distribution
|
# Remove unnecessary toctree for each distribution
|
||||||
|
@ -185,20 +192,22 @@ function build_rst {
|
||||||
else
|
else
|
||||||
BUILD_DIR="${DOC_DIR}${book}/build/html"
|
BUILD_DIR="${DOC_DIR}${book}/build/html"
|
||||||
DOCTREES="${BUILD_DIR}.doctrees"
|
DOCTREES="${BUILD_DIR}.doctrees"
|
||||||
tox -evenv "sphinx-build -j $NUMBER_OF_CORES -q -E -D language=${language} \
|
tox -evenv "sphinx-build -j $NUMBER_OF_CORES \
|
||||||
|
-q -E -D language=${language} \
|
||||||
-d ${DOCTREES} \
|
-d ${DOCTREES} \
|
||||||
${DOC_DIR}${book}/source/ \
|
${DOC_DIR}${book}/source/ \
|
||||||
${BUILD_DIR}"
|
${BUILD_DIR}"
|
||||||
mkdir -p publish-docs/${language}/${book}/
|
mkdir -p publish-docs/${language}/${book}/
|
||||||
rsync -a ${DOC_DIR}${book}/build/html/ publish-docs/${language}/${book}/
|
rsync -a ${DOC_DIR}${book}/build/html/ \
|
||||||
|
publish-docs/${language}/${book}/
|
||||||
fi
|
fi
|
||||||
# Remove newly created files
|
# Remove newly created files
|
||||||
git clean -f -q ${DOC_DIR}${book}/source/locale/${language}/LC_MESSAGES/*.po
|
git clean -f -q ${LOCALE_DIR}${language}/LC_MESSAGES/*.po
|
||||||
git clean -f -x -q ${DOC_DIR}${book}/source/locale/${language}/LC_MESSAGES/*.mo
|
git clean -f -x -q ${LOCALE_DIR}${language}/LC_MESSAGES/*.mo
|
||||||
git clean -f -q ${DOC_DIR}${book}/source/locale/*.pot
|
git clean -f -q ${LOCALE_DIR}*.pot
|
||||||
# Revert changes to po file
|
# Revert changes to po file
|
||||||
git reset -q ${DOC_DIR}${book}/source/locale/${language}/LC_MESSAGES/${book}.po
|
git reset -q ${LOCALE_DIR}${language}/LC_MESSAGES/${book}.po
|
||||||
git checkout -- ${DOC_DIR}${book}/source/locale/${language}/LC_MESSAGES/${book}.po
|
git checkout -- ${LOCALE_DIR}${language}/LC_MESSAGES/${book}.po
|
||||||
# Revert changes to conf.py
|
# Revert changes to conf.py
|
||||||
git reset -q ${DOC_DIR}${book}/source/conf.py
|
git reset -q ${DOC_DIR}${book}/source/conf.py
|
||||||
git checkout -- ${DOC_DIR}${book}/source/conf.py
|
git checkout -- ${DOC_DIR}${book}/source/conf.py
|
||||||
|
@ -263,7 +272,8 @@ function handle_draft_language {
|
||||||
for book in ${DRAFTS["$language"]}; do
|
for book in ${DRAFTS["$language"]}; do
|
||||||
case "${book}" in
|
case "${book}" in
|
||||||
config-reference)
|
config-reference)
|
||||||
mv publish-docs/$language/draft/$book publish-docs/draft/$language/$book
|
mv publish-docs/$language/draft/$book \
|
||||||
|
publish-docs/draft/$language/$book
|
||||||
rmdir --ignore-fail-on-non-empty publish-docs/$language/draft
|
rmdir --ignore-fail-on-non-empty publish-docs/$language/draft
|
||||||
;;
|
;;
|
||||||
firstapp)
|
firstapp)
|
||||||
|
@ -281,7 +291,8 @@ function handle_draft_language {
|
||||||
rmdir --ignore-fail-on-non-empty publish-docs/$language/
|
rmdir --ignore-fail-on-non-empty publish-docs/$language/
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
mv publish-docs/$language/$book publish-docs/draft/$language/$book
|
mv publish-docs/$language/$book \
|
||||||
|
publish-docs/draft/$language/$book
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
@ -320,7 +331,8 @@ fi
|
||||||
source $CONF_FILE
|
source $CONF_FILE
|
||||||
|
|
||||||
if [[ -z $(declare -p BOOKS 2> /dev/null | grep 'declare -A BOOKS') || \
|
if [[ -z $(declare -p BOOKS 2> /dev/null | grep 'declare -A BOOKS') || \
|
||||||
-z $(declare -p DIRECTORIES 2> /dev/null | grep 'declare -A DIRECTORIES') || \
|
-z $(declare -p DIRECTORIES 2> /dev/null | \
|
||||||
|
grep 'declare -A DIRECTORIES') || \
|
||||||
-z $DOC_DIR ]]; then
|
-z $DOC_DIR ]]; then
|
||||||
echo "Error: the configuration file '$CONF_FILE' is invalid"
|
echo "Error: the configuration file '$CONF_FILE' is invalid"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Reference in New Issue