Python sphinx 将plantuml图嵌入到文档字符串中的某个位置(使用Sphinx plantuml扩展)

Python sphinx 将plantuml图嵌入到文档字符串中的某个位置(使用Sphinx plantuml扩展),python-sphinx,docstring,plantuml,Python Sphinx,Docstring,Plantuml,我安装了sphinxcontrib plantuml扩展,如果我运行HTML builder(例如,针对相应的testmodule.py文件使用以下testmodule.rst文件),该扩展可以正常工作: testmodule module ================= .. automodule:: testmodule :members: :undoc-members: :show-inheritance: .. uml:: Alice -&g

我安装了sphinxcontrib plantuml扩展,如果我运行HTML builder(例如,针对相应的testmodule.py文件使用以下testmodule.rst文件),该扩展可以正常工作:

testmodule module
=================

.. automodule:: testmodule
    :members:
    :undoc-members:
    :show-inheritance:

.. uml::
   
   Alice -> Bob: Hi!
   Alice <- Bob: How are you?
testmodule模块
=================
.. 自动模块::测试模块
:成员:
:观察员委员会成员:
:显示继承:
.. uml::
爱丽丝->鲍勃:嗨!

Alice直接在docstring部分添加UML图对我来说不起作用。 但以下几点对我起了作用:

  • 将plantuml代码放在单独的文件中,例如diagram.uml:

  • 您是否尝试在文档字符串中添加UML图?怎么搞的?
    @startuml
       Alice -> Bob: Hi!
       Alice <- Bob: How are you?
    @enduml
    
    def example():
        """
        some text
    
        .. uml:: diagram.uml
    
        some more text 
        """
        ...