When declaring a class that inherits from a specific class:
class C(dict):
added_attribute = 0
the documentation for class C
lists all the methods of dict
(either through help(C)
or pydoc
).
Is there a way to hide the inherited methods from the automatically generated documentation (the documentation string can refer to the base class, for non-overwritten methods)? or is it impossible?
This would be useful: pydoc
lists the functions defined in a module after its classes. Thus, when the classes have a very long documentation, a lot of less than useful information is printed before the new functions provided by the module are presented, which makes the documentation harder to exploit (you have to skip all the documentation for the inherited methods until you reach something specific to the module being documented).
I had the same problem and solved it on Python 2.7.6 for Windows (x86) by adding 3 lines to pydoc.py. Instructions:
find all occurences of the inherited
variable (3 times, on my count) in the file and set it to an empty list right after it is defined. For example, I got line 809:
attrs, inherited = _split_list(attrs, lambda t: t[2] is thisclass)
and wrote inherited = []
on a new line below it.
Now it doesn't print inherited methods anymore.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With