#!/bin/bash

# Exit if errors during script execution
set -e

# Get the package version or exit
version="$(cat VERSION)"
if [ -z "${version}" ]; then
    (>&2 echo "ERROR - VERSION file cannot be found in current directory : ${PWD##*/}");
    exit 1;
fi

# Generate docs folder
sphinx-apidoc --force --full \
    --separate --private --module-first \
    -H "Quackamollie Model Langchain Simple" \
    -A "Forge of Absurd Ducks" \
    -V "${version}" \
    -R "${version}" \
    --implicit-namespaces \
    --ext-autodoc --ext-doctest --ext-todo --ext-coverage --ext-imgmath --ext-viewcode \
    -o docs \
    src/quackamollie

echo -e "\nSubpackages\n-----------\n\n.. toctree::\n   :maxdepth: 4\n\n   quackamollie.model" >> docs/quackamollie.rst
