问题
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