Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions scripts/autogenerate-table-of-contents.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# - landing pages
# - indexing of the knowledgebase

# Don't exit on errors - we want to collect them all
set +e
# During environment setup fail fast on errors
set -e

# Function to cleanup on exit
cleanup() {
Expand All @@ -21,28 +21,35 @@ trap cleanup EXIT

USE_VENV=false

# Try to create a venv, if that fails fall back to installing packages
# Try to create a venv, if that fails fall back to installing package
if [ ! -d "venv" ]; then
echo "Creating virtual environment..."
if python3 -m venv venv 2>/tmp/venv_err.log; then
USE_VENV=true
echo "Using virtualenv at ./venv"
else
echo "Warning: could not create venv, falling back to user site-packages."
cat /tmp/venv_err.log
rm -rf venv
fi
else
USE_VENV=true
echo "Reusing existing virtualenv at ./venv"
fi

if [ "$USE_VENV" = true ]; then
. venv/bin/activate
echo "Installing requirements into virtualenv..."
pip install -r scripts/table-of-contents-generator/requirements.txt
else
# No working venv, install deps
echo "No working venv, installing requirements with python3 -m pip --user..."
python3 -m pip install --user -r scripts/table-of-contents-generator/requirements.txt
fi

# From here on don't exit on the first error, we want to collect which
# TOC commands succeed and which fail.
set +e

# Define all TOC generation commands
COMMANDS=(
'--dir="knowledgebase" --single-toc --out="static" --ignore images'
Expand Down