I am using Sphinx to generate documentation from my docstrings, which are formatted in the Sphinx style. According to PEP-257 I should be using the verb "override" and "extend" to indicate if inherited methods are replaced or called.
If a class subclasses another class and its behavior is mostly inherited from that class, its docstring should mention this and summarize the differences. Use the verb "override" to indicate that a subclass method replaces a superclass method and does not call the superclass method; use the verb "extend" to indicate that a subclass method calls the superclass method (in addition to its own behavior).
As I am new to this it is not clear to me how I should do this in the Sphinx format. Do I simply use one of the words in my description or is there a key like :return:
that I should apply? This instruction is given on the subclass level, is that where the verbs go or do I add them to the individual methods as well?
class A:
"""This is my base class."""
def method_a(self):
"""My base method a."""
pass
def method_b(self):
"""My base method b."""
pass
class B(A):
"""This is the subclass that inherits from :class: A."""
def method_a(self):
"""This method replaces the inherited method_a."""
print("overridden")
def method_b(self):
"""This method calls the inherited method_b."""
super(B, self).method_b()
print("extended")
What would a simple but correct set of docstrings for class B
and its methods look like?