I have two classes which share an API through duck typing, but do not share any inheritance:
class A:
def method():
"""Does something."""
pass
class B:
def method():
pass
I have written docstrings for A
, but not B
. Since the two classes share the same API semantics, their docstrings are mostly the same. I do not wish to repeat the same docstrings in two different places.
If B
inherited from A
, then autodoc has tools to inherit parent class docstrings, but I don't want B
to inherit from A
.
I could make both classes inherit from an abc.ABC
abstract class and put the docstrings there, but that would be a lot of added code for no purpose other than documentation.
Is there any way to tell autodoc to copy the docstrings from another class?