#!/bin/bash
set -euo pipefail
cd "$(dirname "$0")/../../.."
bazel run //ci/zimbeast/docs:run_sphinx -- $PWD/local_docs/ci/zimbeast/docs/html
if [[ -v DISPLAY ]]
then
  echo "Opening web browser..."
  xdg-open local_docs/ci/zimbeast/docs/html/index.html
else
  echo "DISPLAY not available, launching web server..."
  echo "Direct browser to: http://`hostname`:8000/ci/zimbeast/docs/html/index.html"
  echo "--- Ctrl-c to exit ---"
  ( cd local_docs ; python3 -m http.server 8000 )
fi
