سؤال

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?

هل كانت مفيدة؟

المحلول

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
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top