Import doc-tools-check-languages and improve it
This is an initial import of an improved version of tools/test-languages.sh used in repositories like openstack-manuals or security-doc. Following improvements are included: * add missing license header * fix E003: Indent not multiple of 4 * fix E020: Function declaration not in format "^function name {$" * rename variables inside methods * rewrite usage information * refactor/rename methods (test_fr, test_ja, test_language, setup_lang) Change-Id: I9fead76f6552fd3f7317605f1e6a0f9cf5b69b26
This commit is contained in:
parent
0180dbe580
commit
7a9f2623d6
|
@ -6,6 +6,8 @@ Release notes
|
||||||
|
|
||||||
* ``openstack-doc-test``: Don't always build the HOT guide
|
* ``openstack-doc-test``: Don't always build the HOT guide
|
||||||
* ``openstack-dn2osdbk``: Allow single files as source
|
* ``openstack-dn2osdbk``: Allow single files as source
|
||||||
|
* Imported and improved ``doc-tools-check-languages`` (recently known
|
||||||
|
as ``tools/test-languages.sh`` in the documentation repositories).
|
||||||
|
|
||||||
0.17
|
0.17
|
||||||
----
|
----
|
||||||
|
|
|
@ -0,0 +1,117 @@
|
||||||
|
#!/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.
|
||||||
|
|
||||||
|
function setup_directory {
|
||||||
|
language=$1
|
||||||
|
shift
|
||||||
|
for book in "$@" ; do
|
||||||
|
echo " $book"
|
||||||
|
openstack-generate-docbook -l $language -b $book
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function setup_language {
|
||||||
|
language=$1
|
||||||
|
shift
|
||||||
|
echo "Setting up files for $language"
|
||||||
|
echo "======================="
|
||||||
|
echo " Directories:"
|
||||||
|
setup_directory $language 'common' 'glossary' "$@"
|
||||||
|
cp doc/pom.xml generated/$language/pom.xml
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function test_language {
|
||||||
|
language=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Building for language $language"
|
||||||
|
echo
|
||||||
|
|
||||||
|
setup_language $language $@
|
||||||
|
|
||||||
|
args=("-v")
|
||||||
|
if [[ $PURPOSE -eq "publish" ]]; then
|
||||||
|
args+=("--publish")
|
||||||
|
fi
|
||||||
|
args+=("--check-build" "-l $language")
|
||||||
|
for book in "$@"; do
|
||||||
|
args+=("--only-book $book")
|
||||||
|
done
|
||||||
|
|
||||||
|
openstack-doc-test ${args[@]}
|
||||||
|
|
||||||
|
if [[ $? -eq 0 ]] ; then
|
||||||
|
echo "... succeeded"
|
||||||
|
else
|
||||||
|
echo "... failed"
|
||||||
|
BUILD_FAIL=1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function test_ja {
|
||||||
|
test_language 'ja' 'high-availability-guide' \
|
||||||
|
'image-guide' 'install-guide' 'user-guide' \
|
||||||
|
'user-guide-admin'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function test_fr {
|
||||||
|
test_language 'fr' 'user-guide'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function usage {
|
||||||
|
echo "usage: $0 PURPOSE LANGUAGE1 LANGUAGE2 ..."
|
||||||
|
echo
|
||||||
|
echo "PURPOSE is either 'test' or 'publish'."
|
||||||
|
echo "LANGUAGE is either 'fr', 'ja' or 'all'."
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
test|publish)
|
||||||
|
PURPOSE=$1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
BUILD_FAIL=0
|
||||||
|
for language in "$@" ; do
|
||||||
|
case "$language" in
|
||||||
|
all)
|
||||||
|
test_fr
|
||||||
|
test_ja
|
||||||
|
;;
|
||||||
|
fr)
|
||||||
|
test_fr
|
||||||
|
;;
|
||||||
|
ja)
|
||||||
|
test_ja
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
BUILD_FAIL=1
|
||||||
|
echo "Language $language not handled"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
exit $BUILD_FAIL
|
|
@ -24,6 +24,8 @@ packages =
|
||||||
data_files =
|
data_files =
|
||||||
share/openstack-doc-tools/sitemap = sitemap/*
|
share/openstack-doc-tools/sitemap = sitemap/*
|
||||||
share/openstack-doc-tools/cleanup = cleanup/*
|
share/openstack-doc-tools/cleanup = cleanup/*
|
||||||
|
scripts =
|
||||||
|
bin/doc-tools-check-languages
|
||||||
|
|
||||||
[global]
|
[global]
|
||||||
setup-hooks =
|
setup-hooks =
|
||||||
|
|
Loading…
Reference in New Issue