微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

有没有一种方法可以将序列图嵌入rustdoc?

如何解决有没有一种方法可以将序列图嵌入rustdoc?

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

解决方法

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

/// 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 {

}

最终将像这样渲染:

generated docs

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

,

您是否看过: https://docs.rs/crate/mdbook-plantuml/0.3.0

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

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。