Sphinx: Place heading between automethod entries

谁都会走 提交于 2020-04-14 08:18:27

问题


I'm using Sphinx to document a class with a lot of methods. I'd like to group the methods into sections, separated by headers, like this:

.. autoclass:: MyClass

   .. automethod:: __init__

   FooBar Methods
   --------------

   .. automethod:: foo
   .. automethod:: bar

   BazQux Methods
   --------------

   .. automethod:: baz
   .. automethod:: qux

But that doesn't seem to work. Is it possible to somehow break the method list up into named sections?


回答1:


Sections with headings are top-level constructs and they can't be used inside directives. But rubric works. Example:

.. autoclass:: MyClass

   .. automethod:: __init__

   .. rubric:: FooBar Methods

   .. automethod:: foo
   .. automethod:: bar


来源:https://stackoverflow.com/questions/36392554/sphinx-place-heading-between-automethod-entries

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