Make doc-tools-check-languages configurable

Change-Id: Ib5ae5af106b0944cac5a10477bca448cdbf5351a
This commit is contained in:
Christian Berendt 2014-08-01 22:22:41 +02:00
parent c0325f910b
commit 2e55d768ba
2 changed files with 59 additions and 37 deletions

View File

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

View File

@ -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"
)