Я хочу задокументировать некоторые классы, которые являются производными от одного и того же базового класса с некоторыми общими атрибутами, и я хотел бы повторить документацию для каждого атрибута в подклассах, чтобы я мог видеть все атрибуты для класса в одном месте.
Так, например, у меня есть этот код:
class Base(object):
"""Base class."""
#: First attribute
a = int
#: Second attribute
b = str
class FirstChild(Base):
"""First Child of Base."""
#: Child attribute
c = float
class SecondChild(Base):
"""Second Child of Base."""
pass
и у меня это сначала:
.. automodule:: example
:members:
:show-inheritance:
Результат будет таким:
class class example.Base
Bases: "object"
Base class.
a
First attribute
alias of "int"
b
Second attribute
alias of "str"
class class example.FirstChild
Bases: "example.Base"
First Child of Base.
c
Child attribute
alias of "float"
class class example.SecondChild
Bases: "example.Base"
Second Child of Base.
Есть ли способ создать документацию, чтобы дочерние классы также имели унаследованные атрибуты?
Например:
class class example.FirstChild
Bases: "example.Base"
First Child of Base.
a
First attribute
alias of "int"
b
Second attribute
alias of "str"
c
Child attribute
alias of "float"
class class example.SecondChild
Bases: "example.Base"
Second Child of Base.
a
First attribute
alias of "int"
b
Second attribute
alias of "str"