用于 matlab 的 sphinx 中的继承图

inheritance-diagrams in sphinx for matlab

我正在记录我使用 sphinx 的 matlab 代码。我正在使用包 sphinxcontrib-matlabdomain.

我的目录树如下:

me:~/.../doc$ tree ../
../
├── doc
│   ├── conf.py
│   ├── make.bat
│   ├── Makefile
│   ├── index.rst
│   ├── BaseClass.rst
│   └── DerivedClass.rst
├── LICENSE.md
├── README.md
└── src
    ├── BaseClass.m
    └── DerivedClass.m

当我想显示继承图时,问题就来了。我已经在我的 config.py 文件中添加了必要的东西:

matlab_src_dir = os.path.abspath('..')

extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.inheritance_diagram',
    'sphinx.ext.graphviz',
    'sphinx.ext.viewcode',
    'sphinxcontrib.matlab',
]
primary_domain = 'mat'

我在 index.rst 文件中有以下内容

Welcome to BGK's documentation!
===============================

I am trying to have a diagram here...

.. inheritance-diagram:: BaseClass DerivedClass
   :parts:2

.. graphviz::

   digraph {
      "From here" -> "To" -> "Somewhere";
      "From here" -> "To" -> "Somewhere else";
   }

并且在输出中指令 inheritance-diagram 被忽略,直接获取我用来测试我可以绘制图表的下一个图表。

使用 sphinx for matlab 绘制继承图是否不兼容 类?有什么办法可以解决这个问题吗?谢谢!

Sphinx 不支持此功能。 built-in sphinx.ext.inheritance_diagram 扩展仅适用于 Python 域。它不适用于 Matlab。如果是这样,我敢肯定它会在 Sphinx 文档中这样说(并且浏览 sphinx/ext/inheritance_diagram.py 中的源代码确认它仅适用于 Python)。

Matlab 的继承图可以工作的唯一方法是其他扩展提供该功能。您使用的 sphinxcontrib-matlabdomain 扩展没有。