Can I add a horizontal bar to a table of contents in Sphinx?

人走茶凉 提交于 2020-05-31 04:06:13

问题


I'm developing documentation in Sphinx, and would like to separate sections in my table of contents using horizontal bars.

I often see this in menus:

Is there a way to do it in sphinx?


回答1:


The python sphinx .. toctree:: directive doesn't allow much variation besides the documents you include in the directive body, plus a few directive options.

What I've seen others do in this case is splitting one toctree into several, including reStructuredText in between them.

You could use an alternative to the toctree. Quoting the documentation:

Note

For local tables of contents, use the standard reST contents directive.

The easiest way is splitting the menu into several toctrees including a HTML horizontal ruler between them:

Sphinx_test
===========


.. toctree::
   :maxdepth: 4

   undo
   redo

.. raw:: html

   <hr>

.. toctree::
   :maxdepth: 4

   cut
   copy

.. raw:: html

   <hr>

.. toctree::
   :maxdepth: 4

   find
   Speech

And the result:



来源:https://stackoverflow.com/questions/61502938/can-i-add-a-horizontal-bar-to-a-table-of-contents-in-sphinx

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