主页

索引

模块索引

搜索页面

PlantUML插件

备注

本插件是对plantuml格式文件在sphinx上的支持。实践不太好用,编译时总是切java编译器,不能干别的事。

PlantUML插件 [2]

安装:

$ pip install sphinxcontrib-plantuml

启动扩展:

extensions = ['sphinxcontrib.plantuml']

增加plantuml命令:

1. 在conf.py指定命令
plantuml = 'java -jar /path/to/plantuml.jar'

或

2. install a wrapper script in your PATH:
$ cat <<EOT > /usr/local/bin/plantuml
#!/bin/sh -e
java -jar /path/to/plantuml.jar "$@"
EOT
% chmod +x /usr/local/bin/plantuml

使用1:

.. uml::

   Alice -> Bob: Hi!
   Alice <- Bob: How are you?

使用2-指定文件:

.. uml:: /folder/file/external.uml

指定height, width, scale and align:

.. uml::
   :scale: 50 %
   :align: center

   Foo <|-- Bar

指定标题:

.. uml::
   :caption: Caption with **bold** and *italic*
   :width: 50mm

   Foo <|-- Bar

其他方法

假嵌入plantuml.jar [1]

说明:

本质是在make时生成对应的png文件
使用方式不如上面直接使用『PlantUML插件』的方式好

在项目下:

$ cd <project>
$ mkdir _utils
$ cp plantuml.jar _utils

新增cfg文件到_utils目录下:

skinparam backgroundColor white

skinparam note {
    BackgroundColor #F1FFFF
    BorderColor #2980B9
}

skinparam activity {
    BackgroundColor #BDE3FF
    ArrowColor #2980B9
    BorderColor #2980B9
    StartColor #227BC6
    EndColor #227BC6
    BarColor #227BC6
}

skinparam sequence {
    ArrowColor  #2980B9
    DividerBackgroundColor  #BDE3FF
    GroupBackgroundColor    #BDE3FF
    LifeLineBackgroundColor white
    LifeLineBorderColor #2980B9
    ParticipantBackgroundColor  #BDE3FF
    ParticipantBorderColor  #2980B9
    BoxLineColor    #2980B9
    BoxBackgroundColor  #DDDDDD
}

skinparam actorBackgroundColor #FEFECE
skinparam actorBorderColor    #A80036

skinparam usecaseArrowColor   #A80036
skinparam usecaseBackgroundColor  #FEFECE
skinparam usecaseBorderColor  #A80036

skinparam classArrowColor #A80036
skinparam classBackgroundColor    #FEFECE
skinparam classBorderColor    #A80036

skinparam objectArrowColor    #A80036
skinparam objectBackgroundColor   #FEFECE
skinparam objectBorderColor   #A80036

skinparam packageBackgroundColor  #FEFECE
skinparam packageBorderColor  #A80036

skinparam stereotypeCBackgroundColor  #ADD1B2
skinparam stereotypeABackgroundColor  #A9DCDF
skinparam stereotypeIBackgroundColor  #B4A7E5
skinparam stereotypeEBackgroundColor  #EB937F

skinparam componentArrowColor #A80036
skinparam componentBackgroundColor    #FEFECE
skinparam componentBorderColor    #A80036
skinparam componentInterfaceBackgroundColor   #FEFECE
skinparam componentInterfaceBorderColor   #A80036

skinparam stateBackgroundColor #BDE3FF
skinparam stateBorderColor #2980B9
skinparam stateArrowColor #2980B9
skinparam stateStartColor black
skinparam stateEndColor   black

修改Makefile文件:

// 本质是把 uml 文件夹下的 uml 文件编译成图片,放到同级别目录下的 uml_generated 文件夹中
@java -jar _utils/plantuml.jar -charset UTF-8 -config _utils/plantuml.cfg \
  -psvg -o ../uml_generated/ ./uml/*.uml %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%

使用:

.. image:: uml_generated/test.png
  :align: center

plantweb方法

安装:

plantweb安装
$ sudo pip3 install plantweb

说明:

好像只能用于readthedocs
Plantweb is an excellent way to display and render PlantUML, Graphviz and Ditaa diagrams
    in ReadTheDocs published documentation.

主页

索引

模块索引

搜索页面