我尝试使用 Sphinx 和 sphinxcontrib-matlabdomain 包记录一个更大的 Matlab 项目。它适用于存储所有 .m 文件的单个文件夹。但是我的项目包含多个存储在单独文件夹中的类,例如:
project
|-- matfiles
| |-- @class1
| | |-- class1.m
| | |-- method1.m
| | |-- method2.m
| | +-- method1.m
| |-- @class2
| | |-- class2.m
| | |-- methodA.m
| | |-- methodB.m
| | +-- methodC.m
| +-- function
| |-- fun1.m
| |-- fun2.m
| +-- fun3.m
+-- doc
|-- conf.py
+-- index.rst
我将以下行添加到 conf.py
:
matlab_src_dir = os.path.abspath('..')
extensions = [
'sphinx.ext.autodoc',
'sphinxcontrib.matlab',
]
primary_domain = 'mat'
我在 index.rst
中添加了以下几行:
.. module:: matfiles
.. automethod:: class1.method1
我收到以下错误:
Exception occurred:
File "/Library/Python/2.7/site-packages/sphinxcontrib/mat_documenters.py", line 788, in import_object
if self.object.attrs.get('Static'):
AttributeError: 'NoneType' object has no attribute 'attrs'
The full traceback has been saved in /var/folders/70/g0lr37wn60gbbymnsks_t5vm0000gn/T/sphinx-err-uD8qpe.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
| reading sources... [100%] index
所以我的问题是,有没有一种方法可以记录多类 Matlab 项目,其中类方法保存在名为 @class 的文件夹中?
最佳答案
我相信这个问题已经在最新版本中得到解决,sphinxcontrib-matlabdomain-0.2.7 ,它自动记录类方法,其属性定义在 @classfolders
的单独文件中。让我知道这是否仍然是一个问题。
关于python - 如何使用 sphinxcontrib-matlabdomain 记录具有多个类的 Matlab 项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29662470/