重构程序文件目录结构并更新相关路径引用
- 创建新的目录结构:research/、tools/(含子目录)和apps/ - 移动核心理论文件到research/core-theory/ - 移动天山理论文件到research/specialized/ - 重组tools/目录为多个子目录:content-generation/、data-processing/等 - 更新所有文档中的路径引用,包括README.md、项目结构说明.md等 - 更新工作流文件和脚本中的路径引用 - 更新文档索引文件中的路径引用
This commit is contained in:
49
tools/content-generation/generate_ebook.py
Normal file
49
tools/content-generation/generate_ebook.py
Normal file
@@ -0,0 +1,49 @@
|
||||
import subprocess
|
||||
import os
|
||||
import shutil
|
||||
|
||||
def generate_ebook(source_dir="documentation/docs", build_dir="documentation/docs/_build", output_format="epub"):
|
||||
"""
|
||||
使用 Sphinx 生成电子书 (EPUB 或 HTML)。
|
||||
"""
|
||||
print(f"开始生成 {output_format} 格式的电子书...")
|
||||
|
||||
# 确保构建目录存在
|
||||
if not os.path.exists(build_dir):
|
||||
os.makedirs(build_dir)
|
||||
|
||||
# 清理之前的构建
|
||||
if os.path.exists(build_dir):
|
||||
shutil.rmtree(build_dir)
|
||||
print(f"清理目录: {build_dir}")
|
||||
else:
|
||||
print(f"构建目录不存在,无需清理: {build_dir}")
|
||||
|
||||
# 构建文档
|
||||
build_command = [
|
||||
f"./documentation/analysis/phallic-worship-analysis/venv/bin/sphinx-build",
|
||||
"-b", output_format,
|
||||
source_dir,
|
||||
os.path.join(build_dir, output_format)
|
||||
]
|
||||
print(f"执行构建命令: {' '.join(build_command)}")
|
||||
try:
|
||||
subprocess.run(build_command, check=True, cwd='.')
|
||||
print(f"{output_format} 电子书生成成功!")
|
||||
return True
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"生成 {output_format} 电子书失败: {e}")
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
# 示例用法:生成 EPUB
|
||||
if generate_ebook(output_format="epub"):
|
||||
print("EPUB 电子书已生成。")
|
||||
else:
|
||||
print("EPUB 电子书生成失败。")
|
||||
|
||||
# 示例用法:生成 HTML
|
||||
if generate_ebook(output_format="html"):
|
||||
print("HTML 网站已生成。")
|
||||
else:
|
||||
print("HTML 网站生成失败。")
|
||||
Reference in New Issue
Block a user