Getting the right image in a readme file using Sphinx

I want to include an image in my readme.rst file and whether it displays correctly both in Github and in the documentation generated by Sphinx on ReadTheDocs

The file structure is as follows:

readme.rst         # first readme
docs/
    index.rst
    readme.rst     # second readme
    images/
         my_image.png

The second readme file contains

.. include:: ../readme.rst

If I specify the path for my_image in the first readme file as

.. image:: images/my_image.png

It displays correctly in the documentation generated by sphinx, both locally and on the ReadTheDocs website. However, it does not appear in the readme section on Github.

For it to appear on Github, I need to change the path to

.. image:: docs/images/my_image.png

but it is no longer displayed in the local sphinx or on the ReadTheDocs website.

, ... - /, , ( ..include Sphinx )?

+4

Source: https://habr.com/ru/post/1568622/


All Articles