Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DOC: Clarify SVG hyperlink behavior in gallery hyperlinks example#31497

Draft
jayaprajapatii wants to merge 5 commits intomatplotlib:mainfrom
jayaprajapatii:fix-svg-hyperlink-doc
Draft

DOC: Clarify SVG hyperlink behavior in gallery hyperlinks example#31497
jayaprajapatii wants to merge 5 commits intomatplotlib:mainfrom
jayaprajapatii:fix-svg-hyperlink-doc

Conversation

@jayaprajapatii
Copy link
Copy Markdown
Contributor

@jayaprajapatii jayaprajapatii commented Apr 13, 2026

Closes #31452

Summary

Show the generated SVG outputs in the hyperlinks example by including them in the documentation.

Problem

The example generated SVG files with hyperlinks, but they are not visible in the documentation, which makes the output unclear.

Solution

The example still generates SVG files as before.
Since Sphinx renders SVGs as static images, the documentation now displays the rendered outputs (static images) so that the results are visible.

Impact

  • Makes SVG outputs visible in the documentation
  • Improves clarity of the example
  • No functional changes

@github-actions github-actions Bot added the Documentation: examples files in galleries/examples label Apr 13, 2026
Copy link
Copy Markdown
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the intended solution for #31452

Instead, we want to show the SVG images. There are to possible approaches

  • the difficult one: make sphinx-gallery (optionally) support creating SVG output.
  • the hacked one: render the SVG image locally and add it as a static image to the example.

@jayaprajapatii
Copy link
Copy Markdown
Contributor Author

@timhoffm Thanks for the clarification!

I understand that the goal is to actually show the SVG output rather than just explain the behavior. I’ll work on implementing the second approach by rendering the SVG locally and adding it as a static image to the example.

Copy link
Copy Markdown
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing svg files and inappropirate comment location/(maybe) content.

Please take more care in veryifing the result of your changes.

Comment on lines +16 to +22
# NOTE:
# Hyperlinks in SVG output may not appear interactive in the documentation
# because Sphinx renders SVGs as static images (<img> tags),
# so hyperlinks are not clickable
# The SVG images are shown below.
# To see working hyperlinks, open the generated SVG file directly in a browser.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This renders as a comment in the code, which is not appropriate. Instead it should be regular example text.

Also, I'm not clear whether the content is correct. If we show the svgs here, is it still needed to open the files separately in a browser?

Copy link
Copy Markdown
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I urge you to validate your proposals locally before pushing to a public PR. - Or at the very least mark your PR as draft until you are sure it does the right thing.

Posting half-baked PRs causes unnecessary reviewer effort. In the interest of project health, we can only tolerate so much of this. Continued deficits in PR quality may lead to closure.

# %%
# Display generated SVGs in docs
#
# .. image:: scatter.svg
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SVGs do not appear in the documentation. Likely because the generated .rst source file are in a different place than the .py. So the files cannot be found. See also https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#images

@jayaprajapatii
Copy link
Copy Markdown
Contributor Author

@timhoffm Thank you for pointing this out, and sorry for not validating the changes properly before pushing.

I now understand the issue with SVGs not appearing due to incorrect paths. I'll fix this and verify the documentation locally before updating the PR.

@jayaprajapatii
Copy link
Copy Markdown
Contributor Author

Hello @timhoffm
I’ve addressed the previous feedback.

  • Added the generated SVG files to doc/_static
  • Updated the example to correctly reference these SVG files
  • Verified locally using make html.

The outputs are now visible in the documentation.

Please let me know if anything still needs improvement.

@jayaprajapatii jayaprajapatii marked this pull request as ready for review April 19, 2026 16:15
@timhoffm
Copy link
Copy Markdown
Member

I don't understand what's happening here. Can you explain this?

  • previously the example did not show any output
  • now it shows the images right below each example code. Why does this work? Does Sphinx gallery pick up the images you added? But the rendered result is png, not SVG? Does Sphinx convert the SVGs to png?
  • What does the extra section do?
    image

Additionally, we want the SVGs embedded into the HTML, not PNGs as they don't expose the hyperlinks.

@jayaprajapatii jayaprajapatii marked this pull request as draft April 23, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation: examples files in galleries/examples

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Doc]: svg links example should show the svgs?

2 participants