python - 如何使用 sphinxcontrib-matlabdomain 记录具有多个类的 Matlab 项目?

标签 python matlab python-sphinx

我尝试使用 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/

相关文章:

python - 为什么我不断收到错误 "min() arg is an empty sequence"?

css - 如何去除sphinx文档中对内部超链接的强调

terminal - 如何在 Sphinx 中显示终端/外壳代码片段?

Python ctypes 指针和分配的内存

python - 从旧样式自动转换高级字符串格式化程序

python - 无法在 Xpath 中找到值(元素)

matlab - 如何从箱线图中获取离群值及其坐标

c++ - 如何找到近奇异矩阵的逆矩阵?

arrays - Matlab 将二维数组中的数据分组为三元组

virtualenv - 如何让 sphinx 在构建 html 时查找 virtualenv 中的模块?