我正在尝试运行在sphinxcontrib-matlabdomain pypi site上给出的示例/演示,但是autodoc模块无法导入matlab示例文件。
我用sphinx-quickstart
设置了狮身人面像环境。操作系统是Ubuntu 18.04。我的目录结构看起来像这样
root
|--------test_data
| |--MyHandleClass.m
|
|
|--------conf.py
|--------Makefile
|--------index.rst
我的config.py的相关部分是
import os
:
:
extensions = [
'sphinxcontrib.matlab',
'sphinx.ext.autodoc',
]
:
:
matlab_src_dir = os.path.abspath('.')
print "matlab_src_dir: ", matlab_src_dir
第一个文件是从示例中复制的
Test Data
=========
This is the test data module.
.. automodule:: test_data
:mod:`test_data` is a really cool module.
My Handle Class
---------------
This is the handle class definition.
.. autoclass:: MyHandleClass
:show-inheritance:
:members:
运行make html
时的输出是
Running Sphinx v1.8.5
matlab_src_dir: /home/xxxxx/Desktop/sphinxtest
WARNING: while setting up extension sphinx.ext.autodoc: directive 'automodule' is already registered, it will be overridden
WARNING: while setting up extension sphinx.ext.autodoc: directive 'autoclass' is already registered, it will be overridden
WARNING: while setting up extension sphinx.ext.autodoc: directive 'autoexception' is already registered, it will be overridden
WARNING: while setting up extension sphinx.ext.autodoc: directive 'autodata' is already registered, it will be overridden
WARNING: while setting up extension sphinx.ext.autodoc: directive 'autofunction' is already registered, it will be overridden
WARNING: while setting up extension sphinx.ext.autodoc: directive 'automethod' is already registered, it will be overridden
WARNING: while setting up extension sphinx.ext.autodoc: directive 'autoattribute' is already registered, it will be overridden
WARNING: while setting up extension sphinx.ext.autodoc: directive 'autoinstanceattribute' is already registered, it will be overridden
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 0 source files that are out of date
updating environment: [] 0 added, 1 changed, 0 removed
reading sources... [100%] test_data
WARNING: autodoc: failed to import module u'test_data'; the following exception was raised:
No module named test_data
WARNING: don't know which module to import for autodocumenting u'MyHandleClass' (try placing a "module" or "currentmodule" directive in the document, or giving an explicit module name)
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] test_data
generating indices... genindex
writing additional pages... search
copying static files... done
copying extra files... done
dumping search index in English (code: en) ... done
dumping object inventory... done
build succeeded, 10 warnings.
The HTML pages are in _build/html.
我想相信我遵循了发球台上的指示。但是我在这里想念什么吗?
答案 0 :(得分:0)
扩展的顺序很重要,而且从文档中可能还不清楚。因此conf.py
文件应该看起来像这样。
import os
:
:
extensions = [
'sphinx.ext.autodoc',
'sphinxcontrib.matlab',
]
:
:
matlab_src_dir = os.path.abspath('.')
print "matlab_src_dir: ", matlab_src_dir