1

I have a class with a large number of attributes; I would like to present them grouped (rather than in a flat list), with a section-like appearance inside the class documentation.

Is this possible with docutils/sphinx? Any suggestion to achieve something visually similar, perhaps by inserting dummy attributes?

bad_coder
  • 11,289
  • 20
  • 44
  • 72
eudoxos
  • 18,545
  • 10
  • 61
  • 110

1 Answers1

1

Regular reST section headings do not work (see this fairly recent mailing list thread, and also this older thread), but the .. rubric:: directive can be used as a heading in docstrings. Perhaps you can use something like this:

class MyClass(object):
    """
    .. rubric:: Class variables 

    :cvar foo: foo documentation
    :cvar bar: bar documentation

    .. rubric:: Instance variables

    :ivar baz: baz documentation

    """

    pass
mzjn
  • 48,958
  • 13
  • 128
  • 248
  • Very useful and easy workaround. The first thread you mentioned has some rather easy patch to add that functionality to sphinx, hopefully it will be picked up by upstream at some point. – eudoxos Jul 09 '13 at 14:39