【发布时间】:2017-11-15 14:01:27
【问题描述】:
我正在尝试使用 Sphinx 来记录一个基类和 2 个具有 google 样式文档字符串类的子类。我特别纠结于继承的属性:
class Base(object):
"""Base class.
Attributes:
a (int): one attribute
b (int): another one
"""
def __init__(self):
self.a = 3
self.b = 5
class FirstChild(Base):
"""First Child of Base.
Attributes:
c (float): child class attribute
"""
def __init__(self):
self.c = 3.1
class SecondChild(Base):
"""Second Child of Base."""
pass
这是第一个文件:
.. automodule:: my_package.my_module
:members:
:undoc-members:
:show-inheritance:
:inherited-members:
Sphinx 仅在类 Base 上显示属性 a 和 b。在 FirstChild 中,只有 c,在 SecondChild 中没有属性,即使带有 :inherited-members: 标签。
有没有一种方法可以在子类中显示 a、b 和 c,而无需在 FirstChild/SecondChild 文档字符串中复制/粘贴描述?
谢谢!
【问题讨论】:
-
此未决问题与您的问题相似:github.com/sphinx-doc/sphinx/issues/741
标签: python python-sphinx autodoc