当在sphinx中使用plot指令时,我得到以下错误:
...docssourcepyplots/test.py:9: WARNING: Figure caption must be a paragraph or empty comment.
.. figure:: ../../build/html/plot_directive/pyplots/test.png
:align: center
:alt: Some Text.
Some Text.
...docssourcepyplots/test.py:20: WARNING: Figure caption must be a paragraph or empty comment.
.. figure:: ../../build/html/plot_directive/pyplots/test.*
:align: center
:alt: Some Text.
Some Text.
该指令的用法如下:
.. plot:: pyplots/test.py
:align: center
:alt: Schematics of loading on planar shell structures.
Schematics of loading on planar shell structures.
虽然我的图很复杂,但对于包含线形图的非常简单的test.py
也会发生这种情况。
如果我不使用任何选项(align
等)或不写标题,则不会引发错误。真正让我感到困惑的是错误消息中添加的换行符。不知何故,figure指令接收了额外的换行符。
我错过了什么?我可以同时指定选项和标题吗?
编辑:有问题的源代码在这里
matplotlib听起来类似于在Sphinx中使用带有标题选项的graphviz。
试试这个?
.. plot:: pyplots/test.py
:align: center
:alt: Schematics of loading on planar shell structures.
:caption: Schematics of loading on planar shell structures.
尽管根据matplotlib.sphinxext的文档。指令,您应该能够指定内容作为标题。也许使用显式选项名称对您有用?
最后,您在错误消息中看到的额外换行符可能是clue。我会检查源文件中的行尾是否一致。