diff --git a/docs/Makefile b/docs/Makefile index 7fe2c48..a1caa35 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -7,16 +7,33 @@ SPHINXBUILD = sphinx-build SOURCEDIR = . BUILDDIR = _build +LOCALES = $$(echo $(wildcard locales/??) | sed s@locales/@@g) +POT_DIR = _build/gettext + # Put it first so that "make" without argument is like "make help". help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + @echo + @echo publiccode.yml + @echo " \e[31m\e[1mclean\e[0m" "\t" "Clean the build environment" + @echo " \e[31m\e[1mpot_merge_po\e[0m" "\t" "Update the POT file and the language POs" + @echo " \e[31m\e[1mdoc\e[0m" "\t\t" "Build the standard in all the languages" .PHONY: help Makefile clean: - rm -fr _build/?? + rm -fr $(BUILDDIR)/?? rm -f locales/??/LC_MESSAGES/*.mo +pot_merge_po: gettext + @LANG_OPTS=$$(echo $(LOCALES) | sed -E 's@([[:alpha:]]*)*@-l \1@g'); \ + sphinx-intl update -p "${POT_DIR}" $${LANG_OPTS} + +doc: clean + @for lang in $(LOCALES); \ + do make -e SPHINXOPTS="-D language=$${lang}" -e BUILDDIR="_build/$${lang}" rst; \ + done + # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile diff --git a/docs/build.sh b/docs/build.sh deleted file mode 100755 index cacfa03..0000000 --- a/docs/build.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -o nounset -o pipefail - -show_help() { -cat << EOF -Usage: - Extract new strings to translate and update POTs and PO files, if needed. - $0 generate_pot_merge_po - - Generate RST files for all available translations. - $0 generate_doc - - Print this help - $0 --help or -v -EOF -} - -# Autodetect the available locales in the locale/ directory. -LOCALES=(locales/??) -LOCALES=("${LOCALES[@]/locales\//}") - -POT_DIR="_build/gettext/" - -COMMAND=${1:-} - -case "${COMMAND}" in - generate_pot_merge_po) - make gettext - - LANG_OPTS=$(printf -- "-l %s " "${LOCALES[@]}") - sphinx-intl update -p "${POT_DIR}" ${LANG_OPTS} - ;; - generate_doc) - # FIXME: Look into Sphinx not detecting when the .mo changes. - make clean - - LANG_OPTS=$(printf -- "-D language=%s " "${LOCALES[@]}") - - for lang in "${LOCALES[@]}"; do - make -e SPHINXOPTS="-D language=${lang}" -e BUILDDIR="_build/${lang}" rst - done - ;; - ""|-h|--help|*) - show_help - ;; -esac