Browse Source

Make doc-tools-check-languages configurable

Change-Id: Ib5ae5af106b0944cac5a10477bca448cdbf5351a
changes/82/111382/6
Christian Berendt 7 years ago
parent
commit
2e55d768ba
  1. 81
      bin/doc-tools-check-languages
  2. 13
      bin/doc-tools-check-languages.conf

81
bin/doc-tools-check-languages

@ -12,43 +12,42 @@
# License for the specific language governing permissions and limitations
# under the License.
function setup_directory {
BUILD_FAIL=0
function setup_directories {
language=$1
shift
for book in "$@" ; do
echo " $book"
openstack-generate-docbook -l $language -b $book
for directory in ${DIRECTORIES["$language"]} ; do
echo " $directory"
openstack-generate-docbook -l $language -b $directory
done
}
function setup_language {
language=$1
shift
echo "Setting up files for $language"
echo "======================="
echo " Directories:"
setup_directory $language 'common' 'glossary' "$@"
setup_directories $language
cp doc/pom.xml generated/$language/pom.xml
}
function test_language {
language=$1
shift
echo
echo "Building for language $language"
echo
setup_language $language $@
setup_language $language
args=("-v")
if [[ $PURPOSE -eq "publish" ]]; then
args+=("--publish")
fi
args+=("--check-build" "-l $language")
for book in "$@"; do
for book in "${BOOKS["$language"]}"; do
args+=("--only-book $book")
done
@ -63,29 +62,41 @@ function test_language {
}
function test_ja {
test_language 'ja' 'high-availability-guide' \
'image-guide' 'install-guide' 'user-guide' \
'user-guide-admin'
function usage {
echo "usage: $0 CONF_FILE PURPOSE LANGUAGE1 LANGUAGE2 ..."
echo
echo "CONF_FILE is the path to the configuration file."
echo
echo "PURPOSE is either 'test' or 'publish'."
echo
echo "LANGUAGE is either 'all' or 'LANG'."
echo "LANG is a language code like 'fr' or 'ja'."
}
function test_fr {
test_language 'fr' 'user-guide'
}
CONF_FILE=$1
if [[ -z $CONF_FILE ]]; then
usage
exit 1
fi
function usage {
echo "usage: $0 PURPOSE LANGUAGE1 LANGUAGE2 ..."
echo
echo "PURPOSE is either 'test' or 'publish'."
echo "LANGUAGE is either 'fr', 'ja' or 'all'."
}
if [[ ! -e $CONF_FILE ]]; then
echo "Error: the configuration file '$CONF_FILE' does not exist"
exit 1
fi
source $CONF_FILE
case "$1" in
if [[ -z $(declare -p BOOKS 2> /dev/null | grep 'declare -A BOOKS') || \
-z $(declare -p DIRECTORIES 2> /dev/null | grep 'declare -A DIRECTORIES') ]]; then
echo "Error: the configuration file '$CONF_FILE' is invalid"
exit 1
fi
case "$2" in
test|publish)
PURPOSE=$1
PURPOSE=$2
shift
;;
*)
@ -94,22 +105,20 @@ case "$1" in
;;
esac
BUILD_FAIL=0
for language in "$@" ; do
case "$language" in
all)
test_fr
test_ja
;;
fr)
test_fr
;;
ja)
test_ja
for language in "${!BOOKS[@]}"; do
test_language $language
done
;;
*)
BUILD_FAIL=1
echo "Language $language not handled"
if [[ -n ${BOOKS[$language]} ]]; then
test_language $language
else
BUILD_FAIL=1
echo "Error: language $language not handled"
fi
;;
esac
done

13
bin/doc-tools-check-languages.conf

@ -0,0 +1,13 @@
# Example configuration for the languages 'ja' and 'fr'.
# directories to be set up
declare -A DIRECTORIES=(
["ja"]="common glossary high-availability-guide image-guide install-guide user-guide user-guide-admin"
["fr"]="common glossary user-guide"
)
# books to be built
declare -A BOOKS=(
["ja"]="high-availability-guide image-guide install-guide user-guide user-guide-admin"
["fr"]="user-guide"
)
Loading…
Cancel
Save