Skip to content

Commit 656e48c

Browse files
committed
added sphinx-based documentation
1 parent 646d980 commit 656e48c

35 files changed

+478
-34
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Release Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "docs/**"
9+
- "version.txt"
10+
workflow_dispatch:
11+
12+
concurrency:
13+
group: release-docs-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
execute-and-deploy:
18+
runs-on: ubuntu-latest
19+
if: github.repository == 'THUDM/slime'
20+
permissions:
21+
contents: write
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
26+
- name: Setup Python
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: '3.13'
30+
31+
32+
- name: Install dependencies
33+
run: |
34+
apt-get update && apt-get install -y pandoc parallel retry
35+
pip install -r docs/requirements.txt
36+
37+
- name: Build documentation
38+
run: |
39+
cd docs
40+
bash ./build.sh en
41+
bash ./build.sh zh
42+
mv ./build/zh ./build/en/
43+
44+
- name: Deploy
45+
uses: peaceiris/actions-gh-pages@v4
46+
with:
47+
github_token: ${{ secrets.GITHUB_TOKEN }}
48+
publish_dir: ./docs/build/en

docs/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# slime Documentation
2+
3+
We recommend new contributors start from writing documentation, which helps you quickly understand SGLang codebase.
4+
Most documentation files are located under the `docs/` folder.
5+
6+
## Docs Workflow
7+
8+
### Install Dependency
9+
10+
```bash
11+
apt-get update && apt-get install -y pandoc parallel retry
12+
pip install -r requirements.txt
13+
```
14+
15+
### Update Documentation
16+
17+
You can update the documentation in the en and zh folders by adding Markdown or Jupyter Notebook files to the appropriate subdirectories. If you create new files, make sure to update index.rst (or any other relevant .rst files) accordingly.
18+
19+
## Build and Render
20+
21+
```bash
22+
# build english version
23+
bash ./build.sh en
24+
bash ./serve.sh en
25+
26+
# build chinese version
27+
bash ./build.sh zh
28+
bash ./serve.sh zh
29+
```
30+
31+
You can then visit `http://localhost:8000` to view the documentation.

docs/_static/css/custom_log.css

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.output_area {
2+
color: #615656;
3+
}
4+
5+
table.autosummary td {
6+
width: 50%
7+
}
8+
9+
img.align-center {
10+
display: block;
11+
margin-left: auto;
12+
margin-right: auto;
13+
}
14+
15+
.output_area.stderr {
16+
color: #d3d3d3 !important;
17+
}
18+
19+
.output_area.stdout {
20+
color: #d3d3d3 !important;
21+
}
22+
23+
div.output_area.stderr {
24+
color: #d3d3d3 !important;
25+
}
26+
27+
div.output_area.stdout {
28+
color: #d3d3d3 !important;
29+
}

docs/_static/css/readthedocs.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
table.autosummary td {
2+
width: 50%
3+
}
4+
5+
img.align-center {
6+
display: block;
7+
margin-left: auto;
8+
margin-right: auto;
9+
}

docs/_static/image/logo.ico

264 KB
Binary file not shown.

docs/_static/image/logo.jpg

49.3 KB
Loading

docs/build.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
4+
LANG=$1
5+
6+
# make sure language is only en or zh
7+
if [ "$LANG" != "en" ] && [ "$LANG" != "zh" ]; then
8+
echo "Language must be en or zh"
9+
exit 1
10+
fi
11+
12+
cd $SCRIPT_DIR
13+
sphinx-build -b html --conf-dir ./ ./$LANG ./build/$LANG

docs/conf.py

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
import os
2+
import sys
3+
from datetime import datetime
4+
5+
sys.path.insert(0, os.path.abspath("../.."))
6+
7+
__version__ = '0.0.1'
8+
9+
project = "slime"
10+
copyright = f"2025-{datetime.now().year}, slime"
11+
author = "slime Team"
12+
13+
version = __version__
14+
release = __version__
15+
16+
extensions = [
17+
"sphinx.ext.autodoc",
18+
"sphinx.ext.autosummary",
19+
"sphinx.ext.napoleon",
20+
"sphinx.ext.viewcode",
21+
"sphinx.ext.autosectionlabel",
22+
"sphinx.ext.intersphinx",
23+
"sphinx_tabs.tabs",
24+
"myst_parser",
25+
"sphinx_copybutton",
26+
"sphinxcontrib.mermaid",
27+
"nbsphinx",
28+
"sphinx.ext.mathjax",
29+
]
30+
31+
nbsphinx_allow_errors = True
32+
nbsphinx_execute = "never"
33+
34+
autosectionlabel_prefix_document = True
35+
nbsphinx_allow_directives = True
36+
37+
38+
myst_enable_extensions = [
39+
"dollarmath",
40+
"amsmath",
41+
"deflist",
42+
"colon_fence",
43+
"html_image",
44+
"linkify",
45+
"substitution",
46+
]
47+
48+
myst_heading_anchors = 3
49+
50+
nbsphinx_kernel_name = "python3"
51+
nbsphinx_execute_arguments = [
52+
"--InlineBackend.figure_formats={'svg', 'pdf'}",
53+
"--InlineBackend.rc={'figure.dpi': 96}",
54+
]
55+
56+
57+
nb_render_priority = {
58+
"html": (
59+
"application/vnd.jupyter.widget-view+json",
60+
"application/javascript",
61+
"text/html",
62+
"image/svg+xml",
63+
"image/png",
64+
"image/jpeg",
65+
"text/markdown",
66+
"text/latex",
67+
"text/plain",
68+
)
69+
}
70+
71+
myst_enable_extensions = [
72+
"dollarmath",
73+
"amsmath",
74+
"deflist",
75+
"colon_fence",
76+
"html_image",
77+
"linkify",
78+
"substitution",
79+
]
80+
81+
myst_heading_anchors = 3
82+
myst_ref_domains = ["std", "py"]
83+
84+
templates_path = ["_templates"]
85+
86+
source_suffix = {
87+
".rst": "restructuredtext",
88+
".md": "markdown",
89+
}
90+
91+
master_doc = "index"
92+
93+
language = "en"
94+
95+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
96+
97+
pygments_style = "sphinx"
98+
99+
html_theme = "sphinx_book_theme"
100+
html_logo = "_static/image/logo.jpg"
101+
html_favicon = "_static/image/logo.ico"
102+
html_title = project
103+
html_copy_source = True
104+
html_last_updated_fmt = ""
105+
106+
html_theme_options = {
107+
"repository_url": "https://github.com/sgl-project/sgl-project.github.io",
108+
"repository_branch": "main",
109+
"show_navbar_depth": 3,
110+
"max_navbar_depth": 4,
111+
"collapse_navbar": True,
112+
"use_edit_page_button": True,
113+
"use_source_button": True,
114+
"use_issues_button": True,
115+
"use_repository_button": True,
116+
"use_download_button": True,
117+
"use_sidenotes": True,
118+
"show_toc_level": 2,
119+
}
120+
121+
html_context = {
122+
"display_github": True,
123+
"github_user": "sgl-project",
124+
"github_repo": "sgl-project.github.io",
125+
"github_version": "main",
126+
"conf_py_path": "/docs/",
127+
}
128+
129+
html_static_path = ["_static"]
130+
html_css_files = ["css/custom_log.css"]
131+
132+
133+
def setup(app):
134+
app.add_css_file("css/custom_log.css")
135+
136+
137+
myst_enable_extensions = [
138+
"dollarmath",
139+
"amsmath",
140+
"deflist",
141+
"colon_fence",
142+
]
143+
myst_heading_anchors = 5
144+
145+
htmlhelp_basename = "sglangdoc"
146+
147+
latex_elements = {}
148+
149+
latex_documents = [
150+
(master_doc, "sglang.tex", "sglang Documentation", "SGLang Team", "manual"),
151+
]
152+
153+
man_pages = [(master_doc, "sglang", "sglang Documentation", [author], 1)]
154+
155+
texinfo_documents = [
156+
(
157+
master_doc,
158+
"sglang",
159+
"sglang Documentation",
160+
author,
161+
"sglang",
162+
"One line description of project.",
163+
"Miscellaneous",
164+
),
165+
]
166+
167+
epub_title = project
168+
169+
epub_exclude_files = ["search.html"]
170+
171+
copybutton_prompt_text = r">>> |\.\.\. "
172+
copybutton_prompt_is_regexp = True
173+
174+
autodoc_preserve_defaults = True
175+
navigation_with_keys = False
176+
177+
autodoc_mock_imports = [
178+
"torch",
179+
"transformers",
180+
"triton",
181+
]
182+
183+
intersphinx_mapping = {
184+
"python": ("https://docs.python.org/3.12", None),
185+
"typing_extensions": ("https://typing-extensions.readthedocs.io/en/latest", None),
186+
"pillow": ("https://pillow.readthedocs.io/en/stable", None),
187+
"numpy": ("https://numpy.org/doc/stable", None),
188+
"torch": ("https://pytorch.org/docs/stable", None),
189+
}
190+
191+
html_theme = "sphinx_book_theme"
192+
193+
194+
nbsphinx_prolog = """
195+
.. raw:: html
196+
197+
<style>
198+
.output_area.stderr, .output_area.stdout {
199+
color: #d3d3d3 !important; /* light gray */
200+
}
201+
</style>
202+
"""
File renamed without changes.
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# Debugging Guide
2-
3-
[中文版](../zh/debug.md)
1+
# Debugging
42

53
## Aligning Precision
64

0 commit comments

Comments
 (0)