简体   繁体   English

sphinx 文档从以下位置排除了一个基类:inherited-members:

[英]sphinx documentation exclude a baseclass from :inherited-members:

I'm documenting some Python code that has multiple layers of inheritance using Sphinx.我正在使用 Sphinx 记录一些具有多层 inheritance 的 Python 代码。 The structure is roughly:结构大致是:

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

class bar(_foo):
    #do bar stuff

class baz(_foo):
    #do baz stuff

With:inherited-members: in my.rst file I get the documentation from _foo as part of bar and baz but I also get all the documentation from np.ndarray , which I don't want. With:inherited-members: 在 my.rst 文件中,我从_foo获取文档作为barbaz的一部分,但我也从np.ndarray获取所有文档,这是我不想要的。

The Sphinx documentation ( https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html ) says:狮身人面像文档( 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.如果您的 class Foo 派生自列表 class 并且您不想记录 list.__len__(),您应该指定一个选项:inherited-members: list以避免列表 ZA2F2ED4F8EBC2CBB4C21A29DC4 的特殊成员。

But I've tried:但我试过:

  • :inherited-members: np.ndarray :inherited-members: np.ndarray
  • :inherited-members: ndarray :inherited-members: ndarray
  • :inherited-members: numpy.ndarray :继承成员:numpy.ndarray

None of which prevent the entirety of numpy.ndarray documentation being included for every single class.所有这些都不会阻止每个 class 包含整个 numpy.ndarray 文档。 Does anyone know if there's a way to exclude the numpy documentation, but keep the parts I need?有谁知道是否有办法排除 numpy 文档,但保留我需要的部分? Thanks.谢谢。

As explained in comments by @Masklinn, requires version 3.0 or higher, it then works correctly with:正如@Masklinn 在评论中解释的那样,需要 3.0 或更高版本,然后它可以正常工作:

:inherited-members: ndarray

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM