Is it possible embed pictures into docstring in Python?

我怕爱的太早我们不能终老 提交于 2021-02-19 10:14:36

问题


Is it possible embed pictures into docstring in Python?

I saw docpicture keyword somewhere, but can't find doc on it. Is it stabdartized or not?

Where does picture should located?

UPDATE

I tried Sphinx notation, but my PyCharm shows

i.e. it sees that it should be an image here, but doesn't see image file.

Where I would put if used Sphinx?


回答1:


That depends on what tool you use for processing your docstring. Check your tool's documentation to find out how to embed images.

For example, if you are using Sphinx, you can use the image directive, as described in this StackOverflow answer:

.. image:: example.png

Regarding the location of the image, the documentation states:

When used within Sphinx, the file name given [...] must either be relative to the source file, or absolute which means that they are relative to the top source directory. For example, the file sketch/spam.rst could refer to the image images/spam.png as ../images/spam.png or /images/spam.png.



来源:https://stackoverflow.com/questions/45739474/is-it-possible-embed-pictures-into-docstring-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!