#rustdoc #ascii #block #diagram #badascii

macro badascii-doc

Proc-macro to include BadASCII diagrams into your rustdoc output. Block diagrams in ASCII.

4 releases (2 breaking)

Uses new Rust 2024

new 0.4.1 Apr 27, 2025
0.4.0 Apr 27, 2025
0.3.0 Apr 23, 2025
0.1.0 Apr 22, 2025

#675 in Procedural macros

Download history 198/week @ 2025-04-20

200 downloads per month

MIT license

185KB
1.5K SLoC

BADASCII For RustDoc

Use badascii as a macro, and inject cool SVG diagrams into your rustdoc, or wherever you might need them in your rust code.

Using it is super simple.

cargo add badascii-doc

And then in your code, simply use

#![doc = badascii!("
       +-------------+        +-------------+
       | Thing 1     |        | Thing 2     |
       |             |        |             |
  +--->|ins      outs+------->|ins      outs+----+
  |    |             |        |             |    |
  |    |             |        |             |    |
  |    +-------------+        +-------------+    |
  |                                              |
  +----------------------------------------------+
")]

And you will get a nice SVG rendering in your generated markdown. The SVG generated by these macros is meant to be theme-agnostic. They look like this:

SVG of diagram

If you prefer a more formal diagram use the badascii_formal! macro, which gives straight lines and no backtalk.

If you are worried about compile time performance, well, then you can use badascii-cli to process the comments yourself and generate svg images.

Dependencies

~11MB
~191K SLoC