[英]sphinx autodoc for python doesn't show anything (on readthedocs)
I have this python package that I'd like to automatically document using Sphinx. 我有这个python包 ,我想使用Sphinx自动记录。 I've inserted docstrings in every functions and classes.
我在每个函数和类中都插入了docstrings。
I made an account on ReadTheDocs, and did the setup accordingly (ie, a docs/
dir with a conf.py
file). 我在ReadTheDocs上创建了一个帐户,并相应地进行了设置(即带有
conf.py
文件的docs/
dir)。 Then, basically, I've tried almost everything: every combination of autodoc::
, autofunction::
, autoclass::
; 然后,基本上,我已经尝试了几乎所有东西:
autodoc::
, autofunction::
, autoclass::
;的每个组合。 I tried using the same conf.py
file as other packages which documented API (with specific changes made according to my case, of course); 我尝试使用与其他记录API的软件包相同的
conf.py
文件(当然,根据我的情况进行了特定的更改); but it just doesn't work, the API page remains inexorably empty... 但它只是不起作用,API页面仍然空无一人......
Try to add this to your conf.py : 尝试将此添加到您的conf.py:
########### TRICK FOUND ON SOME TUTORIAL : ADD IN THE MOCK_MODULES ANY EXTERNAL MODULE YOU'RE USING IN YOUR PACKAGE.
import mock
MOCK_MODULES = ['numpy', 'scipy', 'sklearn', 'matplotlib', 'matplotlib.pyplot', 'scipy.interpolate', 'scipy.special', 'math', '__future__', 'toolboxutilities']
for mod_name in MOCK_MODULES:
sys.modules[mod_name] = mock.Mock()
In the MOCK_MODULES, add any single external import that your project uses. 在MOCK_MODULES中,添加项目使用的任何单个外部导入。 I had exactly the same problem and this solved it.
我有完全相同的问题,这解决了它。
Also in the conf.py, don't forget to add the : 另外在conf.py中,不要忘记添加:
sys.path.insert(0, os.path.abspath('../..'))
In your case you already have it but I mention it in case someone else with the same problem would see my answer. 在你的情况下你已经拥有它,但我提到它以防其他有相同问题的人会看到我的答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.