在doxygen markdown页面中使用UML图表

5

我正在使用Doxygen来进行个人项目的开发,希望能够在自己创建的页面(Markdown 页面)上使用任何类型的 UML 语言。我并不是要在代码中使用它(这可以实现),而是在由我自己创建的文档中使用,如下面的示例所示:

# Example

sequenceDiagram
    participant Alice
    participant Bob
    Alice->>John: Hello John, how are you?
    loop Healthcheck
        John->>John: Fight against hypochondria
    end
    Note right of John: Rational thoughts <br/>prevail!
    John-->>Alice: Great!
    John->>Bob: How about you?
    Bob-->>John: Jolly good!

```plantuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response

Alice -> Bob: Another authentication Request
Alice <-- Bob: Another authentication Response
```

```mermaid
sequenceDiagram
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response
Alice -> Bob:Another authentication Response
Bob --> Alice: Another authentication Response
```

@startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response

Alice -> Bob: Another authentication Request
Alice <-- Bob: Another authentication Response
@enduml

\startuml
Alice -> Bob: Authentication Request
Bob --> Alice: Authentication Response

Alice -> Bob: Another authentication Request
Alice <-- Bob: Another authentication Response
\enduml

以下是输出结果:

Result

虽然这个文本在typora中可用(mermaid),但在gitlab上与mermaid一起生成的plantuml也能够工作。

doxygen -x Doxyfile 的输出结果:

# Difference with default Doxyfile 1.8.17 (9b14bf58c30a02ef19abebec280568532dc58ed4)
PROJECT_NAME           = Name
PROJECT_NUMBER         = 0.0.1
PROJECT_BRIEF          = "Brief"
OUTPUT_DIRECTORY       = out
INLINE_INHERITED_MEMB  = YES
INPUT                  = ./files \
                         ../src/
RECURSIVE              = YES
PLANTUML_JAR_PATH      = /home/<SURNAME>/Installations/plantuml.jar

问题是:

如何在Doxygen的自定义markdown文件中使用UML图表。


你使用的是哪个版本的doxygen?你可能想要使用\startuml / \enduml命令(就像你在最后几行尝试的那样)。关于三个反引号,已经有一个问题:https://github.com/doxygen/doxygen/issues/7543。为什么在反引号之前使用反斜杠?你有收到任何警告吗? - albert
1
你需要编辑你的问题。仅凭评论是不够的。 - qwerty_so
1
关于 "The \startuml | \enduml markers did not worked either." 这个问题,这可能与您的安装有关。 您是否安装了PlantUML? 您在Doxygen配置文件(Doxyfile)中的 PLANTUML_JAR_PATH 是什么? 您是否收到警告? 请使用doxygen -d extcmd 重新运行以提供由doxygen运行的命令。 如果您从git构建它,则为2019年11月的主版本(1.8.16和1.8.17之间),请提供doxygen -v的输出结果进行简单的设置比较。 - albert
@albert,首先感谢您的帮助。我已经测试了您要求的所有内容(编辑后的问题)。我确实缺少PLANTUML_JAR_PATH,但我已经修复了它,但效果并没有改变。我还在测试代码示例中添加了两个版本(使用@\)。 - Black
3
幸运的是问题已经解决了。Plantuml有时确实有点麻烦,要重新生成图表,必须删除OUTPUT_DIRECTORY中的inline_umlgraph_cache_all.pu文件,否则Doxygen会认为文件已经生成(除非其中一个@startuml代码发生了变化)。 - albert
显示剩余5条评论
1个回答

1

对于你来说可能已经太晚了,但是doxygen在1.9.4版本中现在添加了将plantuml集成到markdown的功能。

在这里,你可以看到如何在你的markdown文件中包含plantuml的示例:

https://github.com/doxygen/doxygen/pull/9198

现在可以像这样使用反引号:

```plantuml

Your Diagram

```

虽然我没有预料到这个问题会引起这么多关注,但我觉得这个答案很有趣。我会在某个时候测试它,并在它有效的情况下接受这个答案 ;) - Black

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接