sphinx 文档从 :inherited-members 中排除了一个基类:

sphinx documentation exclude a baseclass from :inherited-members:

我正在使用 Sphinx 记录一些具有多层继承的 Python 代码。结构大致为:

class _foo(np.ndarray):
    #do _foo stuff

class bar(_foo):
    #do bar stuff

class baz(_foo):
    #do baz stuff

With :inherited-members: 在我的 .rst 文件中,我从 _foo 获得文档作为 barbaz 的一部分,但我也从 np.ndarray,我不想要。

Sphinx 文档 (https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html) 说:

For example; If your class Foo is derived from list class and you don’t want to document list.__len__(), you should specify a option :inherited-members: list to avoid special members of list class.

但我试过了:

None 阻止了每个 class 包含整个 numpy.ndarray 文档。有谁知道是否有办法排除 numpy 文档,但保留我需要的部分?谢谢。

正如@Masklinn 在评论中所解释的那样,需要 3.0 或更高版本,然后才能正常工作:

:inherited-members: ndarray