Modifying options for particular class under automodule directive

Viewed 471

I have a Python module, my_module.py, that looks like this:

import numpy

class A(numpy.ndarray):
    """ Extension for illustration. """
    pass

class B:
    """ My base class. """
    def x():
        """ Does the thing. """
        pass

class C(B):
    """ My extension class. """
    pass

I have a reST file that looks like this:

API Reference
=============

my_module
---------

.. automodule:: my_module
    :members:
    :special_members:

I would like to be able to add an :inherited-members: option to B and C, but not A.

I have attempted to add individual autoclass directives under the automodule:

.. automodule:: my_module
   :members:
   :special_members:

   .. autoclass:: B
      :inherited-members:

   .. autoclass:: C
      :inherited-members:

This has the unintended effect of placing a correctly documented version of B and C, with inherited members, followed by the full documentation of A, B, C, all without inherited members in the same file.

How do I specify different options for some of the members without duplicating the generated documentation?

I am using Sphinx 1.6.3 on an Anaconda install of Python 3.6.2.

2 Answers
Related