【问题标题】:inheritance-diagrams in sphinx for matlab用于 matlab 的 sphinx 中的继承图
【发布时间】:2016-04-18 13:21:51
【问题描述】:

我正在记录我使用 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 为 matlab 类绘制继承图有什么不兼容的地方吗?有没有办法解决这个问题?谢谢!

【问题讨论】:

  • 您可能需要包含该模块以使您的继承图工作:.. inheritance-diagram:: yourModule.BaseClass yourModule.DerivedClass
  • 你好@dfri。我唯一可以考虑作为模块的是包含文件的文件夹。如果我将它添加为.. inheritance-diagram:: src.BaseClass src.DerivedClass,它仍然无法正常工作。我还尝试在所有可能的组合中添加或删除扩展名 .m。它仍然无法正常工作。
  • 据我所知,sphinx.ext.inheritance_diagram 扩展名仅适用于 Python 域。它不适用于 Matlab。
  • 您好@mzjn,您有任何消息来源可以证实这一点吗?在这种情况下,您可以将其发布在答案中,我可以将答案标记为正确。不是我期待的答案:(,但还是谢谢你!

标签: matlab inheritance python-sphinx diagram


【解决方案1】:

Sphinx 不支持这一点。内置的 sphinx.ext.inheritance_diagram 扩展仅适用于 Python 域。它不适用于 Matlab。如果是这样,我相信它会在 Sphinx 文档中这样说(并且看一下 sphinx/ext/inheritance_diagram.py 中的源代码确认它仅适用于 Python)。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-02-06
    • 2013-03-25
    • 2015-05-24
    • 2017-08-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-23
    相关资源
    最近更新 更多