10 releases

0.1.10 May 31, 2021
0.1.9 May 15, 2021
0.1.8 Apr 8, 2021
0.1.6 Jan 28, 2021
0.0.0 Dec 22, 2020

#12 in Visualization

Download history 64/week @ 2021-02-25 166/week @ 2021-03-04 54/week @ 2021-03-11 128/week @ 2021-03-18 99/week @ 2021-03-25 176/week @ 2021-04-01 286/week @ 2021-04-08 231/week @ 2021-04-15 356/week @ 2021-04-22 332/week @ 2021-04-29 271/week @ 2021-05-06 419/week @ 2021-05-13 290/week @ 2021-05-20 475/week @ 2021-05-27 295/week @ 2021-06-03 218/week @ 2021-06-10

1,065 downloads per month
Used in 10 crates (8 directly)

MIT license

1MB
455 lines

Aquamarine

GitHub crates.io docs.rs

Compiler support: this crate requires rustc 1.31.1 or newer

Aquamarine is a procedural macro extension for rustdoc, that aims to improve the visual component of Rust documentation through use of the mermaid.js diagrams.

#[aquamarine] macro works through embedding the mermaid.js into the generated rustdoc HTML page, modifying the doc comment attributes.

To inline a diagram into the documentation, use the mermaid snippet in a doc-string:

#[cfg_attr(doc, aquamarine::aquamarine)]
/// ```mermaid
/// graph LR
///     s([Source]) --> a[[aquamarine]]
///     r[[rustdoc]] --> f([Docs w/ Mermaid!])
///     subgraph rustc[Rust Compiler]
///     a -. inject mermaid.js .-> r
///     end
/// ```
pub fn example() {}

The diagram will appear in place of the mermaid code block, preserving all the comments around it. You can even add multiple diagrams!

To see it in action, go to the demo crate docs.rs page.

light

You can learn more about mermaid.js and what it can do in the mermaid's documentation MdBook

Dark-mode

Aquamarine will automatically select the dark theme as a default, if the current rustdoc theme is either ayu or dark.

You might need to reload the page to redraw the diagrams after changing the theme.

light

Custom themes

Theming is supported on per-diagram basis, through the mermaid's %%init%% attribute.

Note: custom theme will override the default theme

/// ```mermaid
/// %%{init: {
///     'theme': 'base',
///     'themeVariables': {
///            'primaryColor': '#ffcccc', 
///            'edgeLabelBackground':'#ccccff', 
///            'tertiaryColor': '#fff0f0' }}}%%
/// graph TD
///      A(Diagram needs to be drawn) --> B{Does it have 'init' annotation?}
///      B -->|No| C(Apply default theme)
///      B -->|Yes| D(Apply customized theme)
/// ```

custom

To learn more, see the Theming Section of the mermaid.js book

In the wild

Crates that use aquamarine in their documentation

Dependencies

~0.7–1.2MB
~26K SLoC