#!/bin/bash set -euo pipefail IFS=$'\n\t' # Defines SOURCE_DIR="docs" SPHINX_TEMPLATES_DIR="sphinx/templates" mkdir -p "$SPHINX_TEMPLATES_DIR/classes" # This variant comes ordered alphabetically instead of following the TOC, not nice for translators #SPHINX_TEMPLATES=$(find $SPHINX_TEMPLATES_DIR -type f -name "*.pot") # This one is manually maintained, see --templates-list switch SPHINX_TEMPLATES_DOCS=$(sed -e 's@^@'$SPHINX_TEMPLATES_DIR'/@' templates_list.txt) SPHINX_TEMPLATES_CLASSES=$(find "$SPHINX_TEMPLATES_DIR/classes" -type f -name "*.pot") SPHINX_PO_DIR="sphinx/po" SPHINX_BUILD_LANGS=$(cat build_langs.txt) WEBLATE_DIR="weblate/docs" WEBLATE_TEMPLATE="$WEBLATE_DIR/docs.pot" WEBLATE_POFILES=$(find $WEBLATE_DIR -type f -name "*.po" | sort) CLASSES_DIR="weblate/classes" CLASSES_POFILES=$(find $CLASSES_DIR -type f -name "*.po" | sort) # Used only for --add-langs - languages will mostly be added via Weblate directly LANGS="es fr zh_CN" # Options make_templates_list=false update_sphinx_pot=false update_sphinx_po=false update_weblate_pot=false update_weblate_po=false add_langs=false # Command line arguments while [ $# -gt 0 ]; do case "$1" in --templates-list|-tl) make_templates_list=true ;; --sphinx-pot|-st) update_sphinx_pot=true ;; --sphinx-po|-so) update_sphinx_po=true ;; --sphinx|-s) update_sphinx_pot=true update_sphinx_po=true ;; --weblate-pot|-wt) update_weblate_pot=true ;; --weblate-po|-wo) update_weblate_po=true ;; --weblate|-w) update_weblate_pot=true update_weblate_po=true ;; --all|-a) update_sphinx_pot=true update_sphinx_po=true update_weblate_pot=true update_weblate_po=true ;; --add-langs|-l) add_langs=true ;; *) echo "Invalid argument." esac shift done # Make ordered list of Sphinx templates based on table of contents in index.html # This requires having run `make html` in the docs repo and copied the main # `index.html` over next to this script. if [ "$make_templates_list" = true ]; then echo "=== Making ordered list of Sphinx templates based on table of contents ===" if [ ! -f "index.html" ]; then echo "Main 'index.html' file is missing, build it with 'make html' and copy it here." exit 1 fi # The strings we are interested in are of the form: #
  • About