2 releases

0.1.1 Jan 9, 2024
0.1.0 Sep 24, 2023

#4 in #mermaid

Download history 36319/week @ 2024-07-26 34480/week @ 2024-08-02 50123/week @ 2024-08-09 34645/week @ 2024-08-16 42819/week @ 2024-08-23 48752/week @ 2024-08-30 47046/week @ 2024-09-06 43507/week @ 2024-09-13 49644/week @ 2024-09-20 42501/week @ 2024-09-27 53025/week @ 2024-10-04 47979/week @ 2024-10-11 50171/week @ 2024-10-18 46801/week @ 2024-10-25 55991/week @ 2024-11-01 46742/week @ 2024-11-08

207,893 downloads per month
Used in 338 crates (4 directly)

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