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

时间:2015-04-15 23:04:27

标签: python matlab documentation 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的文件夹中?

1 个答案:

答案 0 :(得分:0)

我认为此问题已在最新版本sphinxcontrib-matlabdomain-0.2.7中得到解决,该版本使用@classfolders的单独文件中定义的属性自动记录类方法。如果它还存在问题,请告诉我。