Merge "Base build-openstack-releasenotes on build-reno-releasenotes"
This commit is contained in:
commit
73b7185644
@ -1,4 +0,0 @@
|
||||
- hosts: all
|
||||
roles:
|
||||
- role: fetch-sphinx-output
|
||||
sphinx_output_src: "{{ zuul.project.src_dir }}/releasenotes/build/html"
|
@ -1,4 +0,0 @@
|
||||
- hosts: all
|
||||
roles:
|
||||
- ensure-reno
|
||||
- build-releasenotes
|
@ -1,8 +0,0 @@
|
||||
Build releasenotes for a project, optionally incorporating translations.
|
||||
|
||||
**Role Variables**
|
||||
|
||||
.. zuul:rolevar:: zuul_work_dir
|
||||
:default: {{ zuul.project.src_dir }}
|
||||
|
||||
Directory to build releasenotes in.
|
@ -1 +0,0 @@
|
||||
zuul_work_dir: "{{ zuul.project.src_dir }}"
|
@ -1,128 +0,0 @@
|
||||
# TODO(mordred) Put the translations logic into a sphinx plugin?
|
||||
- name: Check if translations exist for release notes
|
||||
stat:
|
||||
path: "{{ zuul_work_dir }}/releasenotes/source/locale"
|
||||
register: translations
|
||||
|
||||
- name: Prepare release note translations
|
||||
shell:
|
||||
chdir: '{{ zuul_work_dir }}'
|
||||
executable: /bin/bash
|
||||
cmd: |
|
||||
set -e
|
||||
set -x
|
||||
|
||||
DOCNAME=releasenotes
|
||||
DIRECTORY=releasenotes
|
||||
VENV=.venv/bin
|
||||
|
||||
# Mapping of language codes to language names
|
||||
declare -A LANG_NAME=(
|
||||
["de"]="German"
|
||||
["en_AU"]="English (Australian)"
|
||||
["en_GB"]="English (United Kingdom)"
|
||||
["es"]="Spanish"
|
||||
["fr"]="French"
|
||||
["id"]="Indonesian"
|
||||
["it"]="Italian"
|
||||
["ja"]="Japanese"
|
||||
["ko_KR"]="Korean (South Korea)"
|
||||
["pt_BR"]="Portuguese (Brazil)"
|
||||
["ru"]="Russian"
|
||||
["tr_TR"]="Turkish (Turkey)"
|
||||
["zh_CN"]="Chinese (China)"
|
||||
)
|
||||
|
||||
# Check that locale_dirs is really set, otherwise translations
|
||||
# will not work.
|
||||
if ! grep -q -E '^locale_dirs *=' $DIRECTORY/source/conf.py; then
|
||||
echo "Translations exist and locale_dirs missing in source/conf.py"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
REFERENCES=`mktemp`
|
||||
trap "rm -f -- '$REFERENCES'" EXIT
|
||||
|
||||
# Extract translations
|
||||
$VENV/sphinx-build -b gettext \
|
||||
-d ${DIRECTORY}/build/doctrees.gettext \
|
||||
${DIRECTORY}/source/ \
|
||||
${DIRECTORY}/source/locale/
|
||||
|
||||
# Add links for translations to index file
|
||||
cat <<EOF >> ${REFERENCES}
|
||||
|
||||
Translated Release Notes
|
||||
========================
|
||||
|
||||
EOF
|
||||
|
||||
# Check all language translation resources
|
||||
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
|
||||
resname=$(basename ${pot} .pot)
|
||||
|
||||
# Merge all translation resources. Note this is done the same
|
||||
# way as done in common_translation_update.sh where we merge
|
||||
# all strings together in a single file.
|
||||
msgmerge --silent -o \
|
||||
${DIRECTORY}/source/locale/${language}/LC_MESSAGES/${resname}.po \
|
||||
${DIRECTORY}/source/locale/${language}/LC_MESSAGES/${DOCNAME}.po \
|
||||
${pot}
|
||||
# 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 document
|
||||
$VENV/sphinx-build -b html -D language=${language} \
|
||||
-d "${DIRECTORY}/build/doctrees.${language}" \
|
||||
${DIRECTORY}/source/ ${DIRECTORY}/build/html/${language}
|
||||
|
||||
# Reference translated document from index file
|
||||
if [ ${LANG_NAME["${language}"]+_} ] ; then
|
||||
name=${LANG_NAME["${language}"]}
|
||||
name+=" (${language})"
|
||||
echo "* \`$name <${language}/index.html>\`__" >> ${REFERENCES}
|
||||
else
|
||||
echo "* \`${language} <${language}/index.html>\`__" >> ${REFERENCES}
|
||||
fi
|
||||
|
||||
# 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
|
||||
# revert changes to po file
|
||||
git reset -q ${DIRECTORY}/source/locale/${language}/LC_MESSAGES/${DOCNAME}.po
|
||||
git checkout -- ${DIRECTORY}/source/locale/${language}/LC_MESSAGES/${DOCNAME}.po
|
||||
done
|
||||
|
||||
# Now append our references to the index file. We cannot do this
|
||||
# earlier since the sphinx commands will read this file.
|
||||
cat ${REFERENCES} >> ${DIRECTORY}/source/index.rst
|
||||
|
||||
# Remove newly created pot files
|
||||
rm -f ${DIRECTORY}/source/locale/*.pot
|
||||
when: translations.stat.exists == True
|
||||
|
||||
- name: Run releasenotes sphinx build
|
||||
shell:
|
||||
chdir: '{{ zuul_work_dir }}'
|
||||
executable: /bin/bash
|
||||
cmd: |
|
||||
set -e
|
||||
set -x
|
||||
|
||||
VENV=.venv/bin
|
||||
$VENV/sphinx-build -a -E -W -d releasenotes/build/doctrees -b html \
|
||||
releasenotes/source releasenotes/build/html
|
@ -183,7 +183,6 @@
|
||||
nodes:
|
||||
- secondary
|
||||
|
||||
|
||||
- job:
|
||||
name: build-openstack-sphinx-docs
|
||||
parent: tox-docs
|
||||
@ -465,21 +464,14 @@
|
||||
|
||||
- job:
|
||||
name: build-openstack-releasenotes
|
||||
parent: build-reno-releasenotes
|
||||
description: |
|
||||
Build releasenotes, with optional translation support, using reno.
|
||||
success-url: html/
|
||||
run: playbooks/releasenotes/run.yaml
|
||||
post-run: playbooks/releasenotes/post.yaml
|
||||
# Release notes always build on master.
|
||||
override-checkout: master
|
||||
timeout: 1800
|
||||
required-projects:
|
||||
- name: openstack/requirements
|
||||
vars:
|
||||
constraints_file: '{{ ansible_user_dir }}/src/git.openstack.org/openstack/requirements/upper-constraints.txt'
|
||||
files:
|
||||
- ^releasenotes/.*
|
||||
- ^tox.ini
|
||||
|
||||
- job:
|
||||
name: build-openstack-api-ref
|
||||
|
Loading…
x
Reference in New Issue
Block a user