diff --git a/.gitmodules b/.gitmodules index 454b7945..297ce922 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,7 @@ [submodule "_repos/verl"] path = _repos/verl url = https://github.com/volcengine/verl.git + branch = main [submodule "_repos/LLaMA-Factory"] path = _repos/LLaMA-Factory url = https://github.com/the-seeds/LLaMA-Factory-Doc.git diff --git a/Makefile b/Makefile index 3495e930..28f828c1 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ ONNXRUNTIME_CANN_MD_LOCAL := sources/_generated/sources/onnxruntime/quick_start. help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -.PHONY: help Makefile copy-docs clean-submodules fetch-config sync-onnxruntime-doc +.PHONY: help Makefile copy-docs clean-submodules fetch-config sync-onnxruntime-doc init-submodules # Fetch ascend config (always run to ensure freshness) .PHONY: $(ASCEND_CONFIG) @@ -58,13 +58,13 @@ sync-onnxruntime-doc: @rm -f "$(ONNXRUNTIME_CANN_MD_LOCAL).tmp" @echo "Synced to $(ONNXRUNTIME_CANN_MD_LOCAL)" -# Initialize submodules if not exists (use pinned commits for reproducibility) -_repos/verl _repos/VeOmni _repos/LLaMA-Factory _repos/ms-swift: - @echo "Initializing submodules..." - @git submodule update --init +# Initialize submodules (always run to handle empty dirs left by git clone) +init-submodules: + @git submodule sync --recursive + @git submodule update --init --remote # Copy documentation from submodules -copy-docs: _repos/verl _repos/VeOmni _repos/LLaMA-Factory _repos/ms-swift +copy-docs: init-submodules @echo "Preparing generated docs directory..." @mkdir -p $(GENERATED_DOCS) diff --git a/_repos/verl b/_repos/verl index 07d40332..77476af8 160000 --- a/_repos/verl +++ b/_repos/verl @@ -1 +1 @@ -Subproject commit 07d403321fb32aedb0b8eff6e23ecfabed559174 +Subproject commit 77476af84cc074edf5a6437f8d5ea418d7a54916 diff --git a/_static/custom.css b/_static/custom.css index b3b2e0c9..3847cc5e 100644 --- a/_static/custom.css +++ b/_static/custom.css @@ -362,4 +362,34 @@ body.onnxruntime-quickstart-page .rst-content .highlight { } -/* card-icon 样式已移至 index.rst 中统一管理 */ \ No newline at end of file +/* ========================================================= + 独立社区侧边栏专属样式 + ========================================================= */ + +#independent-sidebar .custom-sidebar-caption { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; + font-size: 85%; + color: #0066cc; + font-weight: 700; + text-transform: uppercase; + margin-top: 1.5em; + margin-bottom: 0.5em; + padding-left: 15px; + letter-spacing: 0.5px; +} + +#independent-sidebar ul { + margin-bottom: 0 !important; +} + +/* 覆盖菜单基础项的 padding,使其靠左贴齐 */ +#independent-sidebar ul li.toctree-l1 > a { + padding-left: 15px !important; +} + +#independent-sidebar ul li.toctree-l1.current > a { + background: #e6f0fa; /* 当前选中项高亮背景色 */ + color: #0066cc; + border-left: 4px solid #0066cc; + padding-left: 11px !important; /* 减去边框宽度保持对齐 */ +} diff --git a/_templates/layout.html b/_templates/layout.html new file mode 100644 index 00000000..b470b03c --- /dev/null +++ b/_templates/layout.html @@ -0,0 +1,118 @@ +{% extends "!layout.html" %} + +{% block menu %} +{% if is_independent %} + +
+ + + + + +{% else %} + + {{ super() }} +{% endif %} +{% endblock %} \ No newline at end of file diff --git a/conf.py b/conf.py index 3b0a4410..43d6968d 100644 --- a/conf.py +++ b/conf.py @@ -30,14 +30,32 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'recommonmark', 'sphinx.ext.autodoc', 'sphinxext.remoteliteralinclude', 'sphinx_copybutton', 'sphinx_markdown_tables', "sphinx_design", + 'myst_parser', ] +# 这一行非常重要,它允许 MyST 处理复杂的标题层级 +myst_heading_anchors = 3 + +# 允许在 RST 中嵌入 Markdown 内容 +myst_enable_extensions = [ + "colon_fence", + "html_image", +] + +# conf.py +html_theme_options = { + # 仅显示当前页面所属的导航树,不显示全局无关节点 + 'collapse_navigation': True, + 'navigation_depth': 4, + 'includehidden': True, + 'titles_only': False, +} + # 模板路径设置 templates_path = ['_templates'] autosummary_generate = True @@ -180,6 +198,53 @@ def generate_api_doc(): with open(rst_filename, 'w', encoding='utf-8') as f: f.write(rendered_content) +# ========================================================= +# 独立社区页面全局配置 (核心机制:高度可配置化) +# ========================================================= +html_context = { + 'independent_communities': { + 'verl': { + 'display_name': 'verl', + 'sidebar_mapping': { + 'quick_start': '🚀 快速入门', + 'features': '📚 特性指南', + 'profiling': '⚡ 调优指南', + 'examples': '📊 应用与调优实践', + 'faq': '🔆 故障排查(FAQ)', + 'contribution_guide': '🔧 开源开发' + } + }, + } +} + +# 【新增核心代码】:Sphinx 页面上下文注入 Hook +def update_page_context(app, pagename, templatename, context, doctree): + """ + 拦截页面渲染,判断当前路径是否属于独立社区。 + 如果是,向 Jinja 模板注入 is_independent 和对应的 comm_config 变量。 + 支持两种路径格式: + - sources/verl/... (手写页面) + - sources/_generated/sources/verl/... (从子模块拉取的页面) + """ + communities = context.get('independent_communities', {}) + context['is_independent'] = False + + for comm_id, comm_info in communities.items(): + # 匹配两种路径格式 + if pagename.startswith(f"sources/{comm_id}") or pagename.startswith(f"sources/_generated/sources/{comm_id}"): + context['is_independent'] = True + context['current_community_id'] = comm_id + context['comm_config'] = comm_info + break + +def setup(app): + app.add_css_file('custom.css') + app.add_js_file('package_info.js') + app.add_js_file('statistics.js') + + # 【新增 Hook 注册】 + app.connect('html-page-context', update_page_context) + # 在 Sphinx 构建之前调用该函数生成 API 文档 try: generate_api_doc() diff --git a/index.rst b/index.rst index 35887271..76d2d322 100644 --- a/index.rst +++ b/index.rst @@ -207,7 +207,7 @@用于 LLM 的强化学习训练库,适配昇腾并行计算方案。
- +灵活、高效的大语言模型强化学习训练框架
+ +昇腾环境搭建与基础训练示例
+ + + +昇腾后端特性与一致性说明
+ + + +性能分析与最佳实践案例
+ + + +CI 流程与贡献指南
+ +✨ 核心特性
+ +