简体   繁体   English

如何使用 Sphinx 的 autodoc 记录嵌套类?

[英]How to document nested classes with Sphinx's autodoc?

Is there any way to document a nested class with Sphinx's autodoc plugin?有没有办法用 Sphinx 的 autodoc 插件记录嵌套类?

In:在:

class A:
    class B:
    """
    class B's documentation.
    """

    # ...

I want to use autoclass or something similar in my .rst file to document AB specifically.我想在我的.rst文件中使用autoclass或类似的东西来专门记录AB

I tried:我试过:

.. currentmodule:: package.module

.. autoclass:: A.B

and

.. autoclass:: package.module.A.B

without success:没有成功:

/path/to/file.rst:280: WARNING: autodoc: failed to import class 'B' from module 'package.module.A'; the following exception was raised:

...

Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/sphinx/ext/autodoc.py", line 335, in import_object
    __import__(self.modname)
ImportError: No module named 'package.module.A'; 'package.module' is not a package

Of course A is not a module; A当然不是模块; it seems like autoclass is considering anything before the last .似乎autoclass在最后之前正在考虑任何事情. as packages and modules.作为包和模块。

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

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