Skip to content

DOC [PST] disable gallery link tweaks when html-noplot to avoid warnings #28512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ if "%1" == "html-noplot" (
%SPHINXBUILD% -D plot_gallery=0 -b html %ALLSPHINXOPTS% %BUILDDIR%/html
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/html
goto end
)

if "%1" == "dirhtml" (
Expand Down
24 changes: 15 additions & 9 deletions doc/sphinxext/move_gallery_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,28 @@ def _create_badge_link(link):
sg_note = soup.find("div", class_="sphx-glr-download-link-note")
sg_footer = soup.find("div", class_="sphx-glr-footer")

# If any one of these two is not found, we directly give up tweaking
if sg_note is None or sg_footer is None:
continue

# Move the download links into the secondary sidebar
py_link = sg_footer.find("div", class_="sphx-glr-download-python").a
ipy_link = sg_footer.find("div", class_="sphx-glr-download-jupyter").a
py_link_div = sg_footer.find("div", class_="sphx-glr-download-python")
ipy_link_div = sg_footer.find("div", class_="sphx-glr-download-jupyter")
_create_secondary_sidebar_component(
[
_create_download_link(py_link, is_jupyter=False),
_create_download_link(ipy_link, is_jupyter=True),
_create_download_link(py_link_div.a, is_jupyter=False),
_create_download_link(ipy_link_div.a, is_jupyter=True),
]
)

# Move the badge links into the secondary sidebar
lite_link = sg_footer.find("div", class_="lite-badge").a
binder_link = sg_footer.find("div", class_="binder-badge").a
lite_link_div = sg_footer.find("div", class_="lite-badge")
binder_link_div = sg_footer.find("div", class_="binder-badge")
_create_secondary_sidebar_component(
[_create_badge_link(lite_link), _create_badge_link(binder_link)]
[
_create_badge_link(lite_link_div.a),
_create_badge_link(binder_link_div.a),
]
)

# Remove the sourcelink component from the secondary sidebar; the reason
Expand All @@ -171,9 +178,8 @@ def _create_badge_link(link):
sg_note.extract()
sg_footer.extract()

except Exception as e:
except Exception:
# If any step fails we directly skip the file
logger.warning(f"Failed to tweak gallery links in {html_file}: {e}")
continue

# Write the modified file back
Expand Down