huhan3000/scripts/build_docs.sh

51 lines
1.2 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 胡汉三千年项目文档构建脚本
# Hu-Han Three Thousand Years Project Documentation Build Script
echo "🚀 开始构建胡汉三千年项目文档..."
# 检查是否安装了必要的依赖
echo "📦 检查依赖..."
# 检查Python环境
if ! command -v python3 &> /dev/null; then
echo "❌ 错误未找到Python3"
exit 1
fi
# 检查是否安装了Sphinx
if ! python3 -c "import sphinx" &> /dev/null; then
echo "📥 安装Sphinx..."
pip install sphinx sphinx-rtd-theme myst-parser
fi
# 进入文档目录
cd documentation/sphinx-docs
echo "🧹 清理旧的构建文件..."
make clean
echo "🔨 构建HTML文档..."
make html
if [ $? -eq 0 ]; then
echo "✅ 文档构建成功!"
echo "📖 文档位置: documentation/sphinx-docs/_build/html/index.html"
echo "🌐 可以用浏览器打开查看"
# 如果是在支持的环境中,尝试打开浏览器
if command -v xdg-open &> /dev/null; then
echo "🚀 正在打开浏览器..."
xdg-open _build/html/index.html
elif command -v open &> /dev/null; then
echo "🚀 正在打开浏览器..."
open _build/html/index.html
fi
else
echo "❌ 文档构建失败"
exit 1
fi
cd ../..
echo "🎉 完成!"