#!/bin/bash

# Script to verify MkDocs and its dependencies

echo "=== MkDocs Environment Check ==="
echo ""

# Check Python version
echo "Python version:"
python3 --version
echo ""

# Check MkDocs version
echo "MkDocs version:"
mkdocs --version
echo ""

# Check if cairosvg and PIL are available (needed for social cards)
echo "Checking for cairosvg and PIL (needed for social cards):"
python3 -c "import cairosvg; print('cairosvg is installed')" 2>/dev/null || echo "cairosvg is NOT installed"
python3 -c "from PIL import Image; print('PIL is installed')" 2>/dev/null || echo "PIL is NOT installed"
echo ""

# List all installed MkDocs plugins
echo "Installed MkDocs plugins:"
pip list | grep -i mkdocs
echo ""

# Check specific critical packages
echo "Checking critical dependencies:"
for pkg in cairosvg pillow pymdown-extensions pygments
do
  pip show $pkg 2>/dev/null | grep "^Version:" || echo "$pkg is NOT installed"
done
echo ""

# Test MkDocs build capability
echo "Testing MkDocs build capability:"
cd ~/mkdocs
mkdocs build --dry-run 2>&1 | grep -v "INFO"
echo ""

echo "=== End of Check ==="
