Skip to content

Commit b0ed47d

Browse files
committed
Update
1 parent bce7485 commit b0ed47d

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
@@ -277,21 +277,39 @@ def fix_gallery_edit_links(app, pagename, templatename, context, doctree):
277277
):
278278
parts = pagename.split("/")
279279
gallery_dir = parts[0]
280+
# Handle nested directories by joining all parts except the first
281+
example_path = "/".join(parts[1:])
280282
example_name = parts[-1]
281283

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

290292
if gallery_dir in source_dirs:
291293
source_dir = source_dirs[gallery_dir]
294+
295+
# Reconstruct the path preserving subdirectories
296+
subdir = "/".join(parts[1:-1]) if len(parts) > 2 else ""
297+
292298
# Check if .py file exists
293-
py_path = f"{source_dir}/{example_name}.py"
294-
rst_path = f"{source_dir}/{example_name}.rst"
299+
py_path = (
300+
f"{source_dir}/{subdir}/{example_name}.py"
301+
if subdir
302+
else f"{source_dir}/{example_name}.py"
303+
)
304+
rst_path = (
305+
f"{source_dir}/{subdir}/{example_name}.rst"
306+
if subdir
307+
else f"{source_dir}/{example_name}.rst"
308+
)
309+
310+
# Clean up any double slashes
311+
py_path = py_path.replace("//", "/")
312+
rst_path = rst_path.replace("//", "/")
295313

296314
# Default to .py file, fallback to .rst if needed
297315
file_path = py_path
@@ -342,7 +360,7 @@ def fix_gallery_edit_links(app, pagename, templatename, context, doctree):
342360
"Thumbs.db",
343361
".DS_Store",
344362
"src/pytorch-sphinx-theme/docs*",
345-
# "**/huggingface_hub/templates/**",
363+
# "**/huggindef fix_gallery_edit_linksgface_hub/templates/**",
346364
]
347365
exclude_patterns += sphinx_gallery_conf["examples_dirs"]
348366
exclude_patterns += ["*/index.rst"]

0 commit comments

Comments
 (0)