【发布时间】:2019-05-20 21:59:29
【问题描述】:
当我在本地运行 sphinx(Mac 版 Anaconda Python 3.6.8 上的版本 1.6.6 或 2.0.1)与在 readthedocs.org 上运行它时(根据他们的日志它是 Sphinx),我从 autodoc 得到不同的结果版本 1.8.5,可能还有 Python 2.7,因为它是使用 python 而不是 python3 启动的。
不同之处在于以下文件Shady.Text.rst 的结果,其中包含的内容不超过:
Shady.Text Sub-module
=====================
.. automodule:: Shady.Text
现在,这个子模块恰好只包含一个模块级别的文档字符串,而没有成员文档字符串——这符合预期,因此相应的 html 页面应该包含模块文档字符串,仅此而已。这正是我在本地运行make html 时发生的情况。但是https://shady.readthedocs.io/en/latest/source/Shady.Text.html 的结果是无内容的(只有标题,没有模块文档字符串)。
FWIW 我在 conf.py 中与 autodoc 相关的条目是:
autoclass_content = 'both'
autodoc_member_order = 'groupwise'
我做错了什么?
【问题讨论】:
-
检查build log 以获取这些警告
WARNING: autodoc: failed to import module u'Text' from module u'Shady'; the module executes module level statement and it might call sys.exit(). WARNING: autodoc: failed to import module u'Video' from module u'Shady'; the module executes module level statement and it might call sys.exit(). looking for now-outdated files... none found。最有可能的是,您没有告诉 RTD 安装您的软件包。见docs.readthedocs.io/en/stable/… -
@StevePiercy 谢谢,这让我走上了正轨(见答案)
标签: python-sphinx read-the-docs autodoc