Skip to content

Commit cd69007

Browse files
committed
Update
1 parent 115faa8 commit cd69007

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

.ci/docker/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ sphinxcontrib-mermaid==1.0.0
4545
importlib-metadata==6.8.0
4646

4747
# PyTorch Theme
48-
-e git+https://github.com/pytorch/pytorch_sphinx_theme.git@466e903cc3e2f003ba5b2d52c22168428060ba32#egg=pytorch_sphinx_theme2
48+
-e git+https://github.com/pytorch/pytorch_sphinx_theme.git@pytorch_sphinx_theme2#egg=pytorch_sphinx_theme2
4949
ipython
5050

5151
sphinxcontrib.katex

conf.py

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -280,21 +280,39 @@ def fix_gallery_edit_links(app, pagename, templatename, context, doctree):
280280
):
281281
parts = pagename.split("/")
282282
gallery_dir = parts[0]
283+
# Handle nested directories by joining all parts except the first
284+
example_path = "/".join(parts[1:])
283285
example_name = parts[-1]
284286

285-
source_dirs = {
286-
"beginner": "beginner_source",
287-
"intermediate": "intermediate_source",
288-
"advanced": "advanced_source",
289-
"recipes": "recipes_source",
290-
"prototype": "prototype_source",
291-
}
287+
source_dirs = {}
288+
for i in range(len(sphinx_gallery_conf["examples_dirs"])):
289+
gallery_dir = sphinx_gallery_conf["gallery_dirs"][i]
290+
source_dir = sphinx_gallery_conf["examples_dirs"][i]
291+
# Extract the base name without "_source" suffix
292+
gallery_base = gallery_dir
293+
source_dirs[gallery_base] = source_dir
292294

293295
if gallery_dir in source_dirs:
294296
source_dir = source_dirs[gallery_dir]
297+
298+
# Reconstruct the path preserving subdirectories
299+
subdir = "/".join(parts[1:-1]) if len(parts) > 2 else ""
300+
295301
# Check if .py file exists
296-
py_path = f"{source_dir}/{example_name}.py"
297-
rst_path = f"{source_dir}/{example_name}.rst"
302+
py_path = (
303+
f"{source_dir}/{subdir}/{example_name}.py"
304+
if subdir
305+
else f"{source_dir}/{example_name}.py"
306+
)
307+
rst_path = (
308+
f"{source_dir}/{subdir}/{example_name}.rst"
309+
if subdir
310+
else f"{source_dir}/{example_name}.rst"
311+
)
312+
313+
# Clean up any double slashes
314+
py_path = py_path.replace("//", "/")
315+
rst_path = rst_path.replace("//", "/")
298316

299317
# Default to .py file, fallback to .rst if needed
300318
file_path = py_path
@@ -345,7 +363,7 @@ def fix_gallery_edit_links(app, pagename, templatename, context, doctree):
345363
"Thumbs.db",
346364
".DS_Store",
347365
"src/pytorch-sphinx-theme/docs*",
348-
# "**/huggingface_hub/templates/**",
366+
# "**/huggindef fix_gallery_edit_linksgface_hub/templates/**",
349367
]
350368
exclude_patterns += sphinx_gallery_conf["examples_dirs"]
351369
exclude_patterns += ["*/index.rst"]

0 commit comments

Comments
 (0)