-
Notifications
You must be signed in to change notification settings - Fork 133
Expand file tree
/
Copy pathconf.py
More file actions
102 lines (90 loc) · 3.11 KB
/
Copy pathconf.py
File metadata and controls
102 lines (90 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# Sphinx configuration for the Modern GPU Programming For MLSys book.
# Migrated off d2lbook to plain Sphinx + MyST-Parser + sphinx-book-theme.
# Build: sphinx-build -b html . _build/html
from pathlib import Path
project = "Modern GPU Programming For MLSys"
author = "MLC Community"
copyright = "2026, MLC Community"
release = "0.0.1"
extensions = ["myst_parser", "sphinx_copybutton"]
# Markdown (MyST) is the primary source format.
source_suffix = {".md": "markdown", ".rst": "restructuredtext"}
root_doc = "index"
myst_enable_extensions = [
"dollarmath", # $...$ and $$...$$ math
"amsmath", # LaTeX environments
"colon_fence", # ::: fences
"deflist",
]
myst_heading_anchors = 3 # auto slug anchors for h1-h3
# Only the toctree-reachable docs are content; keep everything else out so
# Sphinx does not warn about / try to render source, build, and asset files.
exclude_patterns = [
"_build",
"Thumbs.db",
".DS_Store",
"README.md",
"**/README.md",
"zh",
"_*.md",
"**/_*.md",
"img/scripts",
".git",
".github",
]
# --- HTML / theme ---
html_theme = "sphinx_book_theme"
html_title = project
html_logo = "static/mlc-logo-with-text-landscape.svg"
html_favicon = "static/mlc-favicon.ico"
html_static_path = ["static"]
# Interactive slide demos (self-contained HTML+CSS+JS) copied verbatim into the
# site root, then embedded via <iframe>. See chapter_* for the embeds.
html_extra_path = ["_extra"]
html_css_files = ["custom.css", "demo-embed.css"]
html_js_files = ["demo-embed.js"]
html_theme_options = {
"show_navbar_depth": 1,
"show_toc_level": 2,
"home_page_in_toc": False,
"navbar_persistent": [],
"repository_url": "https://github.com/mlc-ai/modern-gpu-programming-for-mlsys",
"repository_branch": "main",
"path_to_docs": ".",
"use_repository_button": False,
"use_issues_button": True,
"use_edit_page_button": True,
"use_source_button": True,
"use_download_button": False,
"use_fullscreen_button": False,
"repository_url": "https://github.com/mlc-ai/modern-gpu-programming-for-mlsys",
"use_repository_button": True,
}
def add_language_switch_button(app, pagename, templatename, context, doctree):
"""Add an English-to-Chinese switch to the article header."""
header_buttons = context.get("header_buttons")
if header_buttons is None:
return
zh_source_root = Path(app.srcdir) / "zh"
has_translation = any(
(zh_source_root / f"{pagename}{suffix}").is_file()
for suffix in source_suffix
)
target_page = (
pagename
if has_translation or pagename in {"search", "genindex"}
else "index"
)
zh_url = context["pathto"](f"zh/{target_page}.html", 1)
header_buttons.append(
{
"type": "javascript",
"javascript": f"window.location.href='{zh_url}'",
"tooltip": "切换到中文版",
"icon": "fas fa-language",
"label": "language-switch-button",
"classes": "pst-navbar-icon",
}
)
def setup(app):
app.connect("html-page-context", add_language_switch_button, priority=502)