python-doc-inherit
Utilities to inherit method documentation from parent classes.
Badges
Installation
Install python-doc-inherit:
pip install python-doc-inherit
Usage
Simple method decorator (will cause other decorators to fail)
from doc_inherit import method_doc_inherit
class Foo(object):
def foo(self):
"""Frobber"""
pass
class Bar(Foo):
@method_doc_inherit
def foo(self):
pass
Now, Bar.foo.__doc__ == Bar().foo.__doc__ == Foo.foo.__doc__ == "Frobber"
Simple class decorator
from doc_inherit import class_doc_inherit
class Foo(object):
def foo(self):
"""Frobber"""
pass
@class_doc_inherit
class Bar(Foo):
def foo(self):
pass
Now, Bar.foo.__doc__ == Bar().foo.__doc__ == Foo.foo.__doc__ == "Frobber"
Metaclass
from doc_inherit.metaclasses import DocStringInheritor
from six import add_metaclass # Note: Six is not included in this distribution.
class Animal:
def move_to(self, dest):
"""Move to *dest*"""
pass
@add_metaclass(DocStringInheritor)
class Bird(Animal):
def move_to(self, dest):
pass
Now, Animal.move_to.__doc__ == Bird.move_to.__doc__ == "Move to *dest*"
Running the Tests
pip install -r requirements/test.txt
./runtests.py