Insert clickable SVG image into Sphinx documentation
One simple solution would be to add a link to the svg file in this .. image:: myfile.svg
command:
.. image:: myfile.svg
:target: _images/myfile.svg
Take care of checking the relative directory where the images are copied when the html files are generated. By default, it should be _images/
.
This way, you can click the SVG file, to see it in a plain page, and then click on it as usual (not a perfect solution but still..).
Sphinx generates <img>
tags for images, which makes sense in most cases. However, to have the links inside the svg be clickable, you should use an <object>
tag, i.e.:
.. raw:: html
<object data="myfile.svg" type="image/svg+xml"></object>
(Regarding the GitHub issue you linked to, I don't think there's a lot that Sphinx can do here—it's really quite complicated—short of introducing a new option to the .. image
directive that lets the user specify whether to render as an img
or object
tag.)
I am probably misunderstanding the OP's requirements, but why not just include the SVG into the sphinx documentation as html? This appears to work for me:
.. raw:: html
:file: images/image.svg