Stuart Berg
Stuart Berg

Reputation: 18141

Sphinx: Place heading between automethod entries

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?

Upvotes: 4

Views: 250

Answers (1)

mzjn
mzjn

Reputation: 50947

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

Upvotes: 3

Related Questions