rsdoc

This crate provides a procedural macro that transform PlandUML and Drawio diagrams in doc comments as PNG or SVG images. The diagrams in doc comments as SVG images using [drawio]. The UML diagrams and flow diagrams in doc comments as PNG images using [plantUML].

Requires Rust version 1.54 or later or equivalent nightly builds.

Usage

Add the following line to Cargo.toml.

toml [dependencies] rsdoc = "0.1.0"

plantuml!

Wrap doc comments with #[doc = plantuml!(...)]. Use plantuml code blocks to write uml diagrams. In this way, you can directly use the Alt+D key to browse the UML diagram in the source code after installing the PlantUML plug-in

#[doc = rsdoc::plantuml!(
/// @startuml
/// !theme cyborg-outline
/// Bob -> Alice : hello
/// @enduml
)]
pub fn test_function(){}

Or you can directly attach the puml file stored as a file

#[doc = rsdoc::plantuml_file!(test.puml)]

If you want to attach pictures, such as PNG or SVG, you can do it this way

#[doc = rsdoc::image!(test.png)]

And you can also use it with the Drawio tool, hope you like it!

#[doc = rsdoc::image!(test.drawio.svg)]

See the example directory for a complete example.

Tips

License: MIT/Apache-2.0