我一直在使用 Sphinx 为我的代码制作一个很好的文档,我想知道是否可以在目录旁边放置一个图像(而不是一个没有任何东西的大空白)
现在,我初学者的 index.rst 文件看起来像这样:
.. XXXXXX documentation master file, created by
sphinx-quickstart on Wed Apr 11 13:59:42 2018.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to XXXXXX's documentation!
==================================
.. topic:: the_topic
.. todo:: write topic
.. toctree::
:maxdepth: 2
:caption: Contents:
Tool1
Tool2
Tool3
Tool4
Tool5
Tool6
Tool7
Tool8
.. image:: _static/my_image.png
:align: center
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
提前致谢。
最佳答案
是的,这是可能的。将 image
指令放在 toctree
指令之前。然后使用 common option ,像这样:
.. image:: _static/my_image.png
:class: align-right
Sphinx 默认样式表 basic.css
可能已经存在于您的主题中,并且已经设置了一个样式来使图像向右浮动。如果没有,则使用本地 CSS 文件覆盖主题的 CSS,或向主题添加新的 CSS 文件,在其中定义新样式。
img.align-right {float: right;}
关于使用 python-Shinx 在重组文本中并排显示图像和目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49812096/