Chilipp / autodocsumm

Extending your autodoc API docs with a summary
Apache License 2.0
48 stars 14 forks source link

add option to list inherited attributes & methods too #9

Closed maeddlae closed 5 years ago

maeddlae commented 5 years ago

It is not possible to show inherited attributes and methods in sub class

Chilipp commented 5 years ago

Hello @maeddlae, thanks for submitting this issue! autodocsumm uses the flags provided to autodoc. Hence, it generates an entry in the table for each attribute that is documented by autodoc.

By default, autodoc does not document inherited members. Therefore, if you want to include them, you have to include the :inherited-members: flag for the corresponding directive (see the autodoc docs)

To be safe, I added tests for it for autodocsumm in 23c30e4b7d01160feda5006b8f2d8285080b82a6 and the inheritance is working.

The objective of autodocsumm is to create a table for the attributes that are documented in detail by autodoc. Do you think it would be helpful to allow the documentation of more than that?

maeddlae commented 5 years ago

My bad, you are right. I just forgot to redefine the base class attribute in sub class in order to make it appear. This code is now summarized as it should (except of https://github.com/Chilipp/autodocsumm/issues/8):

class Example():
    """
    class documentation
    """
    class_variable = 12 #: This is a classvariable

    def __init__(self):
        """
        constructor doc
        """
        self.instance_variable = 34 #: This is an instance variable

class Inherits(Example):
    """
    class documentation
    """
    another_class_variable = 12 #: This is another classvariable
    class_variable = Example.class_variable #: This is a classvariable from base class

    def __init__(self):
        """
        constructor doc
        """
        self.another_instance_variable = 34 #: This is another instance variable
        self.instance_variable = self.instance_variable #: This is an instance variable from base class

image