-
-
Notifications
You must be signed in to change notification settings - Fork 196
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
Support embedding local images (through reST directives) #282
Comments
Hey there! Thanks for the extensive write-up. I think images in the docstrings is a reasonable feature request. Some thoughts on this:
|
Hey @mhils For 1, it may be some issue on my end. I'll check and get back on this. I don't know much about HTML/CSS or I'd try to implement this myself! But I'm happy y'all will consider this. Cheers! |
Hi, Only the public URLs image works for me |
One (maybe slightly crazy) way to embed images without caring where they're located (and thereby circumventing any <img src="data:image/png;base64,[BASE64_OF_IMAGE]"> You can actually automate this if you are using Python's built-in
I'm running a customized version of the above in my CI and the results are satisfactory. There are some downsides to embedding the image though:
so the main tradeoff is bandwidth (though the HTML is usually compressed so the downloaded result is still of reasonable size). |
Problem Description
First of all, it's great to see this package being developed again! I've only just begun converting my docstrings into external documentation and this looks like it will be a great fit for what I need!
"A picture is worth a thousand words" and this is sometimes especially true for documentation! Well-written documentation should always be the standard of course, and I'm very glad this project makes it easier to read docs in a browser rather than having to always read the code docstrings themselves. Sometimes, though, being able to include an image for a difficult operation or concept would make a world of difference.
For instance, my research focuses on a subfield of deep learning. Having a way to display small images/graphs of before and after a function is run on an array (or something similar) would go a long way into making certain difficult operations easier to conceptualize for myself and others.
Proposal
It would be great if this project added a way to include images into the output HTML files. One way to do this might be to use the reST directive
.. image::
which could easily be added to the bottom of a docstring. That way, the docstring itself is minimally disrupted, but when viewing the generated external documentation, images could be easily seen.Additionally, an extra bonus would be if this supported the google doc style instead of only restructured text. I mention this because including markdown files mentions using the
__docformat__ = "restructuredtext"
, and I assume if adding images were to be supported, it might be done in a similar way. Unfortunately our code follows the Google doc style and setting__docformat__ = "restructuredtext"
messes up the rendering.Alternatives
I've considered using small Markdown snippets like
and then including them in a docstring via
However, this only displays the text content of the markdown file and not the included image.
Additional context
This is something that pdoc3 says they support through the reST
.. image::
directive so hopefully it wouldn't be too much trouble to also integrate it here. I haven't tried using this feature from that package, but their documentation does say it is an option.This looks similar to #272, however, I'm only concerned with being able to include images in the static HTML files, not display any warnings or caution symbols. Additionally, I believe (or hope! 😁 ) that this is within the scope of the project as markdown does support image display, while it didn't have native admonition support.
The text was updated successfully, but these errors were encountered: