Can pydoc / help () hide documentation for inherited class methods and attributes?

When declaring a class that inherits from a particular class:

class C(dict):
    added_attribute = 0

the documentation for the class Clists all methods dict(either through help(C)or pydoc).

Is there a way to hide inherited methods from automatically generated documentation (the documentation line may refer to the base class for unwritten methods)? or is it impossible?

This would be useful: pydoclists the functions defined in the module after its classes. Thus, when classes have very long documentation, before publishing the new functions provided by the module, much less useful information is printed, which complicates the work of the documentation (you need to skip all the documentation for the inherited methods until you reach something specific for the documented module).

+5
source share
3 answers

pydoc help , , (, pydoc), , . dict , , , doc.

+2

, Python 2.7.6 Windows (x86), 3 pydoc.py. :

  • Lib\pydoc.py
  • inherited (3 , ) . , 809:

    attrs, inherited = _split_list (attrs, lambda t: t [2] thisclass)

inherited = [] .

.

+1

You can assign a class to a metaclass using a special method __dir__that returns its own list of attributes. Pydoc will use this list.

Notes:

  • it will also affect behavior dir().
  • In rare cases, the use of metaclasses is known to open a portal to hell.
0
source

All Articles