Switch to translated docs build by openstackdocstheme
Change-Id: Ic10b4bfa469ac11e278bd0ecd8088418d61c4fd5
This commit is contained in:
parent
9de6fb3d0e
commit
f91deab8fe
@ -20,7 +20,7 @@ monotonic==1.4
|
||||
msgpack==0.5.6
|
||||
netaddr==0.7.19
|
||||
netifaces==0.10.6
|
||||
openstackdocstheme==1.20.0
|
||||
openstackdocstheme==1.28
|
||||
oslo.config==5.2.0
|
||||
oslo.context==2.20.0
|
||||
oslo.i18n==3.20.0
|
||||
|
@ -2,8 +2,8 @@
|
||||
# of appearance. Changing the order has an impact on the overall integration
|
||||
# process, which may cause wedges in the gate later.
|
||||
beautifulsoup4>=4.6.0 # MIT
|
||||
lxml!=3.7.0,>=3.4.1 # BSD
|
||||
oslo.log>=3.36.0 # Apache-2.0
|
||||
requests>=2.14.2 # Apache-2.0
|
||||
six>=1.10.0 # MIT
|
||||
lxml!=3.7.0,>=4.1.1 # BSD
|
||||
oslo.log>=3.37.0 # Apache-2.0
|
||||
requests>=2.18.4 # Apache-2.0
|
||||
six>=1.11.0 # MIT
|
||||
PyYAML>=3.12 # MIT
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
hacking<0.11,>=0.10.2 # Apache-2.0
|
||||
|
||||
Babel!=2.4.0,>=2.3.4 # BSD
|
||||
sphinx!=1.6.6,!=1.6.7,>=1.6.2 # BSD
|
||||
openstackdocstheme>=1.18.1 # Apache-2.0
|
||||
doc8>=0.6.0 # Apache-2.0
|
||||
Babel!=2.4.0,>=2.5.3 # BSD
|
||||
sphinx!=1.6.6,!=1.6.7,>=1.6.5 # BSD
|
||||
openstackdocstheme>=1.28 # Apache-2.0
|
||||
doc8>=0.8.0 # Apache-2.0
|
||||
|
@ -1,178 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# 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.
|
||||
|
||||
# Build English and translated version of the I18n guide.
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
DOCNAME=doc
|
||||
DIRECTORY=doc
|
||||
|
||||
# build i18n contributor guide page
|
||||
sphinx-build -a -W -b html \
|
||||
-d ${DIRECTORY}/build/doctrees \
|
||||
${DIRECTORY}/source ${DIRECTORY}/build/html/
|
||||
|
||||
if [ "${NO_LANG_BUILD:-0}" = "1" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# This function sets the following global variables
|
||||
# - LANG_INDEX : filename which contains the language index
|
||||
# - HAS_LANG : 1 (there are languages other than English), 0 (English only)
|
||||
function prepare_language_index {
|
||||
# Global variables
|
||||
HAS_LANG=0
|
||||
LANG_INDEX=`mktemp`
|
||||
trap "rm -f -- $LANG_INDEX" EXIT
|
||||
|
||||
cat <<EOF >> $LANG_INDEX
|
||||
[
|
||||
\`English <__BASE__/__INDEX__>\`__
|
||||
EOF
|
||||
|
||||
# Generate language index file
|
||||
for locale in `find ${DIRECTORY}/source/locale/ -maxdepth 1 -type d` ; do
|
||||
# skip if it is not a valid language translation resource.
|
||||
if [ ! -e ${locale}/LC_MESSAGES/${DOCNAME}.po ]; then
|
||||
continue
|
||||
fi
|
||||
language=$(basename $locale)
|
||||
|
||||
# Reference translated document from index file
|
||||
echo -n "| " >> $LANG_INDEX
|
||||
HAS_LANG=1
|
||||
get_lang_name_prog=$(dirname $0)/get-lang-display-name.py
|
||||
name=`python3 $get_lang_name_prog $language`
|
||||
echo "\`$name <__BASE__/${language}/__INDEX__>\`__" >> $LANG_INDEX
|
||||
done
|
||||
|
||||
cat <<EOF >> $LANG_INDEX
|
||||
]
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
function _add_language_index {
|
||||
local target_file=$1
|
||||
local basepath=$2
|
||||
|
||||
local basename
|
||||
basename=$(echo $target_file | sed -e "s|$DIRECTORY/source/||" -e "s|\.rst$||")
|
||||
path_to_top_level=$(dirname $basename | sed -e 's|[^./]\+|..|g')
|
||||
|
||||
local _basepath
|
||||
if [ "$basepath" = "." -a "$path_to_top_level" = "." ]; then
|
||||
_basepath="."
|
||||
elif [ "$basepath" = "." ]; then
|
||||
_basepath=$path_to_top_level
|
||||
elif [ "$path_to_top_level" = "." ]; then
|
||||
_basepath=$basepath
|
||||
else
|
||||
_basepath="$basepath/$path_to_top_level"
|
||||
fi
|
||||
|
||||
cp -p $target_file $target_file.backup
|
||||
sed -e "s|__BASE__|$_basepath|" -e "s|__INDEX__|$basename.html|" $LANG_INDEX > $target_file
|
||||
cat $target_file.backup >> $target_file
|
||||
}
|
||||
|
||||
function add_language_index_to_localized {
|
||||
for f in `find $DIRECTORY/source -name '*.rst'`; do
|
||||
_add_language_index $f ..
|
||||
done
|
||||
}
|
||||
|
||||
function add_language_index_to_original {
|
||||
for f in `find $DIRECTORY/source -name '*.rst'`; do
|
||||
cp -p $f.backup $f
|
||||
_add_language_index $REFERENCES $f .
|
||||
done
|
||||
}
|
||||
|
||||
function recover_rst_files {
|
||||
for f in `find $DIRECTORY/source -name '*.rst'`; do
|
||||
mv $f.backup $f
|
||||
done
|
||||
}
|
||||
|
||||
sphinx-build -a -W -b gettext \
|
||||
-d ${DIRECTORY}/build/doctrees.gettext \
|
||||
${DIRECTORY}/source ${DIRECTORY}/source/locale/
|
||||
|
||||
prepare_language_index
|
||||
if [ "$HAS_LANG" = "0" ]; then
|
||||
exit 0
|
||||
fi
|
||||
# Now add our references to the beginning of the index file. We cannot do this
|
||||
# earlier since the sphinx commands will read this file.
|
||||
# Ensure to revert any changes to the index file.
|
||||
add_language_index_to_localized
|
||||
|
||||
# check all language translation resource
|
||||
for locale in `find ${DIRECTORY}/source/locale/ -maxdepth 1 -type d` ; do
|
||||
# skip if it is not a valid language translation resource.
|
||||
if [ ! -e ${locale}/LC_MESSAGES/${DOCNAME}.po ]; then
|
||||
continue
|
||||
fi
|
||||
language=$(basename $locale)
|
||||
|
||||
echo "===== Building $language translation ====="
|
||||
|
||||
# prepare all translation resources
|
||||
for pot in ${DIRECTORY}/source/locale/*.pot ; do
|
||||
# get filename
|
||||
potname=$(basename $pot)
|
||||
resname=${potname%.pot}
|
||||
echo $resname
|
||||
# merge all translation resources
|
||||
msgmerge --silent -o \
|
||||
${DIRECTORY}/source/locale/${language}/LC_MESSAGES/${resname}.po \
|
||||
${DIRECTORY}/source/locale/${language}/LC_MESSAGES/${DOCNAME}.po \
|
||||
${DIRECTORY}/source/locale/${potname}
|
||||
# compile all translation resources
|
||||
msgfmt -o \
|
||||
${DIRECTORY}/source/locale/${language}/LC_MESSAGES/${resname}.mo \
|
||||
${DIRECTORY}/source/locale/${language}/LC_MESSAGES/${resname}.po
|
||||
done
|
||||
|
||||
# build translated guide
|
||||
# build i18n contributor guide page
|
||||
# TODO(amotoki): Enable -W option in translated version
|
||||
sphinx-build -a -b html -D language=${language} \
|
||||
-d ${DIRECTORY}/build/doctrees.languages/${language} \
|
||||
${DIRECTORY}/source ${DIRECTORY}/build/html/${language}
|
||||
|
||||
# remove newly created files
|
||||
git clean -f -q ${DIRECTORY}/source/locale/${language}/LC_MESSAGES/*.po
|
||||
git clean -f -x -q ${DIRECTORY}/source/locale/${language}/LC_MESSAGES/*.mo
|
||||
git clean -f -x -q ${DIRECTORY}/source/locale/.doctrees
|
||||
# revert changes to po file
|
||||
git reset -q ${DIRECTORY}/source/locale/${language}/LC_MESSAGES/${DOCNAME}.po
|
||||
git checkout -q -- ${DIRECTORY}/source/locale/${language}/LC_MESSAGES/${DOCNAME}.po
|
||||
done
|
||||
|
||||
# remove newly created pot files
|
||||
rm -f ${DIRECTORY}/source/locale/*.pot
|
||||
|
||||
add_language_index_to_original
|
||||
|
||||
# build i18n contributor guide page
|
||||
sphinx-build -a -W -b html \
|
||||
-d ${DIRECTORY}/build/doctrees \
|
||||
${DIRECTORY}/source ${DIRECTORY}/build/html/
|
||||
|
||||
recover_rst_files
|
@ -1,24 +0,0 @@
|
||||
# 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.
|
||||
|
||||
import sys
|
||||
|
||||
import babel
|
||||
|
||||
|
||||
lang_code = sys.argv[1]
|
||||
try:
|
||||
l = babel.Locale.parse(lang_code)
|
||||
print(l.get_display_name())
|
||||
except Exception:
|
||||
print(lang_code)
|
6
tox.ini
6
tox.ini
@ -5,7 +5,7 @@ skipsdist = True
|
||||
|
||||
[testenv]
|
||||
basepython=python3
|
||||
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}
|
||||
#install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}
|
||||
usedevelop = True
|
||||
setenv = VIRTUAL_ENV={envdir}
|
||||
deps = -r{toxinidir}/requirements.txt
|
||||
@ -27,12 +27,10 @@ commands = {posargs}
|
||||
passenv =
|
||||
# Required by add-marker.sh
|
||||
ZUUL*
|
||||
# Pass NO_LANG_BUILD=1 if you would like to build English version only
|
||||
NO_LANG_BUILD
|
||||
commands =
|
||||
doc8 doc/source
|
||||
# Build translated guides
|
||||
{toxinidir}/tools/build-docs.sh
|
||||
docstheme-build-translated.sh
|
||||
|
||||
[testenv:pep8]
|
||||
commands =
|
||||
|
Loading…
Reference in New Issue
Block a user