Skip to content

Commit 1b10f71

Browse files
committed
Add new theme
1 parent 6053b2a commit 1b10f71

File tree

2 files changed

+90
-5
lines changed

2 files changed

+90
-5
lines changed

.ci/docker/requirements.txt

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# --extra-index-url https://download.pytorch.org/whl/cu117/index.html # Use this to run/publish tutorials against the latest binaries during the RC stage. Comment out after the release. Each release verify the correct cuda version.
22
# Refer to ./jenkins/build.sh for tutorial build instructions
33

4-
sphinx==5.0.0
4+
sphinx==5.3.0
55
sphinx-gallery==0.11.1
66
sphinx_design
77
docutils==0.16
@@ -40,12 +40,11 @@ onnxscript
4040
onnxruntime
4141
evaluate
4242
accelerate>=0.20.1
43-
43+
sphinxcontrib-mermaid==1.0.0
4444
importlib-metadata==6.8.0
4545

4646
# PyTorch Theme
47-
-e git+https://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
48-
47+
-e git+https://github.com/pytorch/pytorch_sphinx_theme.git@pytorch_sphinx_theme2#egg=pytorch_sphinx_theme2
4948
ipython
5049

5150
sphinxcontrib.katex

conf.py

+87-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131
import sys
3232
sys.path.insert(0, os.path.abspath('.'))
3333
sys.path.insert(0, os.path.abspath('./.jenkins'))
34-
import pytorch_sphinx_theme
34+
import pytorch_sphinx_theme2
35+
36+
html_theme = "pytorch_sphinx_theme2"
37+
html_theme_path = [pytorch_sphinx_theme2.get_html_theme_path()]
3538
import torch
3639
import numpy
3740
import gc
@@ -84,6 +87,14 @@
8487
'sphinx_gallery.gen_gallery',
8588
'sphinx_design',
8689
'sphinx_sitemap'
90+
'sphinxcontrib.mermaid',
91+
'myst_parser'
92+
]
93+
94+
myst_enable_extensions = [
95+
"colon_fence",
96+
"deflist",
97+
"html_image",
8798
]
8899

89100
intersphinx_mapping = {
@@ -130,6 +141,81 @@ def reset_seeds(gallery_conf, fname):
130141
]
131142
sitemap_url_scheme = "{link}"
132143

144+
html_theme_options = {
145+
"navigation_with_keys": False,
146+
"analytics_id": "GTM-T8XT4PS",
147+
"pytorch_project": "tutorials",
148+
"logo": {
149+
"text": "Home",
150+
},
151+
"language_bindings_links": [
152+
{
153+
"url": "https://pytorch.org/docs/stable/cpp_index.html",
154+
"name": "C++",
155+
},
156+
{
157+
"url": "https://pytorch.org/javadoc/",
158+
"name": "Javadoc",
159+
},
160+
{
161+
"url": "https://github.com/pytorch/multipy",
162+
"name": "torch.multiply",
163+
},
164+
],
165+
"external_links": [
166+
{
167+
"name": "Tutorials",
168+
"url": "https://pytorch.org/tutorials/",
169+
},
170+
],
171+
"icon_links": [
172+
{
173+
"name": "X",
174+
"url": "https://x.com/PyTorch",
175+
"icon": "fa-brands fa-x-twitter",
176+
},
177+
{
178+
"name": "GitHub",
179+
"url": "https://github.com/pytorch/pytorch",
180+
"icon": "fa-brands fa-github",
181+
},
182+
{
183+
"name": "Discourse",
184+
"url": "https://dev-discuss.pytorch.org/",
185+
"icon": "fa-brands fa-discourse",
186+
},
187+
{
188+
"name": "PyPi",
189+
"url": "https://pypi.org/project/torch/",
190+
"icon": "fa-brands fa-python",
191+
},
192+
],
193+
"use_edit_page_button": True,
194+
"logo": {
195+
"text": "Home",
196+
},
197+
}
198+
199+
theme_variables = pytorch_sphinx_theme2.get_theme_variables()
200+
201+
html_context = {
202+
"theme_variables": theme_variables,
203+
"display_github": True,
204+
"github_url": "https://github.com",
205+
"github_user": "pytorch",
206+
"github_repo": "pytorch",
207+
"feedback_url": "https://github.com/pytorch/tutorials",
208+
"github_version": "main",
209+
"doc_path": "docs/source",
210+
"library_links": theme_variables.get("library_links", []),
211+
"icon_links": theme_variables.get("icon_links", []),
212+
"community_links": theme_variables.get("community_links", []),
213+
"pytorch_project": "docs",
214+
"language_bindings_links": html_theme_options.get("language_bindings_links", []),
215+
}
216+
217+
218+
133219
if os.getenv('GALLERY_PATTERN'):
134220
# GALLERY_PATTERN is to be used when you want to work on a single
135221
# tutorial. Previously this was fed into filename_pattern, but

0 commit comments

Comments
 (0)