【Hexo】使用PlantUML插件画UML图
# 0. 安装插件
npm install hexo-tag-plantuml --save
# 1. 语法
# 顺序图(Sequence Diagram)
{% plantuml %}
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
Alice -> Bob: Another atuhentication Request
Alice <-- Bob: Another authentication Response
{% endplantuml %}
效果:
{% plantuml %} Alice -> Bob: Authentication Request Bob --> Alice: Authentication Response
Alice -> Bob: Another atuhentication Request Alice <-- Bob: Another authentication Response {% endplantuml %}
# 用例图(Use Case Diagram)
{% plantuml %}
@startuml
(Usecase One)
(Usecase Two) as (UC2)
usecase UC3
usecase (Last\nusecase) as UC4
@enduml
{% endplantuml %}
效果:
{% plantuml %} @startuml (Usecase One) (Usecase Two) as (UC2) usecase UC3 usecase (Last\nusecase) as UC4 @enduml {% endplantuml %}
# 类图(Class Diagram)
{% plantuml %}
@startuml
Class01 <|-- Class02
Class03 *-- Class04
Class05 o-- Class06
Class07 .. Class08
Class09 -- Class10
@enduml
{% endplantuml %}
效果:
{% plantuml %} @startuml Class01 <|-- Class02 Class03 *-- Class04 Class05 o-- Class06 Class07 .. Class08 Class09 -- Class10 @enduml {% endplantuml %}
# 活动图(Activity Diagram)
{% plantuml %}
(*) -up-> "First Activity"
-right-> "Second Activity"
--> "Third Activity"
-left-> (*)
{% endplantuml %}
效果:
{% plantuml %} () -up-> "First Activity" -right-> "Second Activity" --> "Third Activity" -left-> () {% endplantuml %}
更详细的语法说明请到官网 (opens new window)查看
在 Hexo 上使用,则将标准语法放置在 plantuml
标签中即可:
{% plantuml %}
语法
{% endplantuml %}
参考文章:《在 hexo 中使用 PlantUML 来画 UML》 (opens new window)、《plantuml 使用教程【转】》 (opens new window)