#!/bin/bash
# ./generate_txt.py

(cd exos-divers && ./generate)

./generate_markdown calculette

DEFAULT_LANG=fr
LANGS='fr en'

if [ "$1" = fast ]; then
    FAST=true
elif [ "$1" = total ] || [ "$1" = slow ] || [ "$1" = all ]; then
    FAST=false
else
    FAST=false
fi

python3 generate_multilang.py --langs $LANGS

if [ "$FAST" = false ]; then
    # multilang py files
    for n in progra_equivalences theorie1_egal_if; do
        for l in $LANGS; do
            python3 ./generate_html_from_py.py \
                ${n}_${l}.py \
                --template pytext_template.html \
                --out ${n}_${l}.html \
                --langs $LANGS \
                --lang-url=${n}_{lang}.html \
                --lang $l
        done
        for ext in html py; do
            rm -f ${n}.${ext}
            cp ${n}_${DEFAULT_LANG}.${ext} ${n}.${ext}
        done
    done

    # non multilang py files
    for n in theorie2_liste_while theorie3_fonctions_et_objets; do
        python3 ./generate_html_from_py.py \
            ${n}.py \
            --template pytext_template.html \
            --out ${n}.html
    done
else
    echo "FAST generation: skipping generate_html_from_py"
fi

python3 generate_html.py
# ./generate_ln.py
python3 generate_ls.py # keep last

# ./generate_zip
# ./generate_state_svg.py triangle-geometry.svg --layer-name
# ./generate_state_svg.py trigono.svg
