我确信这在某种程度上是用户错误,但我在这里慢慢地发疯了,真的希望能得到一些帮助。
我已经让sphinx-apidoc和优秀的第三方sphinx-autoapi都能工作了,但不能用sphinx.ext.autosummary重复这个把戏。它快把我逼疯了。另外,这两个选项都不能提供真正整洁的包/模块成员汇总表,而这可能是sphinx.ext.autosummary的主要卖点。
我有一个非常简单的项目:
|_ TEST
|_ docs
|_ conf.py
|_ index.rst
|_ myproject
|_ __init__.py
|_ mymodule.pyconf.py看起来像这样:
import os
import sys
sys.path.insert(0, os.path.abspath('../../myproject'))
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosummary'
]
autosummary_generate = Trueindex.rst看起来像这样:
.. autosummary::
:toctree: _autosummary
myproject.mymodulemymodule.py看起来像这样:
"""
Module containing a class and a function.
"""
class TestClass:
"""
A class representing a test.
I wish I could get this to stuff to show up but I can't and I don't know why.
Why isn't this documentation visible?!? :-(
"""
def __init__(self):
"""
Instantiate.
"""
pass
def Func_in_test_class(self):
"""
Cool function that does stuff.
:return: Some new stuff.
"""
pass
def GlobalFunc():
"""
Utility function.
Does some good stuff.
"""
pass从docs目录运行make html就会生成这个可爱的Readthedocs风格的HTML:

我想要做的是单击汇总表中的TestClass函数并访问一个新页面,该页面完整地显示了这个类的API文档。我怎样才能做到这一点呢?
(或者我没有抓住要点,我必须将sphinx.ext.autosummary和sphinx-apidoc结合起来才能得到我需要的东西。)
发布于 2020-06-28 01:30:37
从Sphinx版本3.1 (2020年6月)开始,sphinx.ext.autosummary终于有了递归!
我在这里回答了我自己的问题:https://stackoverflow.com/a/62613202/12014259
https://stackoverflow.com/questions/61576683
复制相似问题