0

I am new to using Sphinx and stumbled upon a problem while using the autodoc function (sphinx-apidoc).

One of my modules defines a function that uses dynamic inheritance, like this:

def generate_object(base_class, *args, **kwargs):
    """This function create a new class that inherits base_class
    """

    class NewClass(base_class):
        """Class that inerherits the base_class
        """

        def __init__(self, *args, **kwargs):
            super(NewClass, self).__init__(*args, **kwargs)
            pass

    return NewClass(*args, **kwargs)

I then use the standard sphinx-quickstart in a docs folder and create the necessary .rst files using

sphinx-apidoc -f -o source/ ../

After running make html from the docs folder the generated site shows the documentation for the generate_object method but not for NewClass. How can I ensure that the documentation for NewClass is generated and shown in the documentation?

The code can be found here, and the documentation here

mzjn
  • 48,958
  • 13
  • 128
  • 248
Bart
  • 11
  • 1
  • `automodule` imports a module in order to document it. But I doubt that it can document a class (with or without dynamic inheritance) whose definition exists in the body of a function in the module. – mzjn Sep 28 '17 at 15:39
  • Is there a recommended way around this? – Bart Sep 28 '17 at 18:18
  • Describing `NewClass` in the docstring of the `generate_object` function is what I can think of. Btw, here is a similar question about documenting classes defined within classes (I don't know if it helps though): https://stackoverflow.com/q/27337534/407651 – mzjn Oct 02 '17 at 10:25

0 Answers0