2 releases

0.1.1 Jan 9, 2024
0.1.0 Sep 24, 2023

#225 in Rust patterns

Download history 206/week @ 2023-12-24 7/week @ 2023-12-31 310/week @ 2024-01-07 468/week @ 2024-01-14 1158/week @ 2024-01-21 812/week @ 2024-01-28 819/week @ 2024-02-04 8756/week @ 2024-02-11 30824/week @ 2024-02-18 30255/week @ 2024-02-25 24284/week @ 2024-03-03 26859/week @ 2024-03-10 29558/week @ 2024-03-17 28107/week @ 2024-03-24 41239/week @ 2024-03-31 33169/week @ 2024-04-07

132,393 downloads per month
Used in 286 crates (via sp-runtime)

MIT license

11KB

simple-mermaid

Simple Mermaid diagrams RustDoc integration

This crate provides a simple declarative macro to include mermaid diagrams in your rustdoc documentation. Lookup the great mermaid documentation for details on the diagram syntax.

Usage

  1. Create your mermaid diagrams in their own files (usually with .mmd or .mermaid extension).
  2. Call the [mermaid!] macro in a #[doc] attribute. Specify the route to the diagram file as a string literal. Note that the path is interpreted relative to the file where the macro is called, as it happens with the underlying include_str.
  3. Done!

Alternatives

aquamarine

The aquamarine introduces a procedural macro that converts regular code blocks marked with the mermaid language tag. It also allows including the diagram from external files, but that comes with some limitations:

  • Only one external diagram can be added to a single doc block.
  • The external diagram will always appear at the end of the doc block.

Those limitations made aquamarine a non-option for me, since I strongly prefer leaving the diagrams in external files for several reasons: clutter, maintainability, IDE support, and, re-usability of the diagrams.

Besides, the declarative macro used in this crate should be easier on compile times. And it comes with no dependencies at all!

rsdoc

The rsdoc crate provides procedural macros to embed PlantUML and images in doc coments. It can be used with code-blocks (similar to aquamarine) or with external files (similar to this crate). So, in this case, for me it was just a matter of personal taste, both PlantUML and mermaid are fantastic opensource projects. But PlantUML is Java... and my plants always die (even a cactus I once had! How can a cactus die? The thing should not need water!).

Disclaimer

Neither this crate nor it's autor have any relation or affiliation with the mermaid project, other that being an user of this magnific library.

All the examples in this documentation have been extracted, verbatim or with minor updates, from the mermaid documentation.

License: MIT

No runtime deps