使用 python-Shinx 在重组文本中并排显示图像和目录

标签 image python-sphinx restructuredtext toctree

我一直在使用 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/

相关文章:

python - 使用 readthedocs.org 使用的静态 Assets 进行本地 Sphinx 构建的简单方法是什么?

python-sphinx - Sphinx 中的常见链接目标

python-sphinx - 有选择地禁用 readthedocs 语法突出显示

restructuredtext - 使用 nbsphinx 阅读文档

python - 如何从 Sphinx 的默认搜索中排除 RST 文件?

css - 图像宽度 100%,无水平滚动

php - Mysql 和 php-拖放图片上传到数据库

带有标签的 Javascript/HTML5 图像查看器

javascript - onClick:在 Facebook 上分享图片

python-sphinx - 如何在 reStructuredText/Sphinx 中创建 float 图形?