【发布时间】:2020-05-16 11:06:47
【问题描述】:
我正在使用:inherited-members: 来显示父方法。
在为子类生成的文档中,是否可以引用子类?
class Parent:
"""This is a {Child class name} class
This is in the {Child group attribute} group
"""
group = ''
...
class Child(Parent):
group = 'TheChild'
...
在为孩子生成的文档中,我想看看:
> class Child(Parent)
> Bases: Parent
> This is a Child class.
> It is in the TheChild group
Sphinx 可以做到这一点吗?
【问题讨论】:
-
在这种情况下,
group(或TheChild组)是什么?是一群孩子吗?是你定义的组吗?是 Child 类的文档字符串吗? -
group 只是一个类属性。我可以很容易地称它为
xyz。每个孩子都将使用自己的值覆盖 group 属性。这有帮助吗? -
即使你能做到,它也会造成一个令人困惑的文档字符串。
-
@user2357112supportsMonica 如果您知道如何阅读 Python Sphinx,这并不令人困惑。此外,对象名称是完全限定的。您可以选择在 docstring 或 rst 文件中记录,该选择由每个开发人员自行决定。除非您制作的 PEP 另有建议。
标签: python parent-child python-sphinx docstring cross-reference