1

正如他们所说,一张照片值 1000 字。我想sequence diagrams在我生成的rust documentation. 有没有办法做到这一点?拥有一个embedded image并没有真正起作用,它更难维护,它是文档之外的资产,等等。

4

2 回答 2

3

最通用的方法只是非代码代码块中的基于文本的图表。

/// This module contains structs and functions for communicating to and from
/// the server. It is very important that you understand this diagram so you
/// will appreciate how much work has gone into this. Just look at it! Its
/// beautiful!
/// 
/// ```none
/// +------------+          +------------+
/// |   Client   |          |   Server   |
/// +------------+          +------------+
///       |                        |
///       | request("/")           |
///       +----------------------> |
///       |                        |
///       |             response() |
///       | <----------------------+
///       |                        |
///       |                        |
///       v                        v
/// ```
/// 
/// Appreciating the diagram will give you a +1 to confidence for the rest of
/// the day.
pub mod connection {

}

最终会像这样渲染:

生成的文档

这是否可以接受和/或实用取决于您。

于 2020-10-14T08:25:06.970 回答
1

你看过了吗: https ://docs.rs/crate/mdbook-plantuml/0.3.0

Plantuml 是一个非常好的工具,可以使用易于维护的文本来描述序列图。这是来自Plantuml 网站的示例:

在此处输入图像描述

于 2020-10-14T07:38:18.880 回答