#svg #diagram #documentation #figure #rustdoc #proc-macro

macro svgbobdoc

Renders ASCII diagrams in doc comments as SVG images

10 releases

0.3.0 Mar 16, 2022
0.3.0-alpha.4 Dec 18, 2021
0.3.0-alpha.3 Nov 28, 2021
0.3.0-alpha.1 Jul 23, 2021
0.2.0 May 30, 2019

#894 in Text processing

Download history 2638/week @ 2024-02-26 2813/week @ 2024-03-04 3484/week @ 2024-03-11 3660/week @ 2024-03-18 2664/week @ 2024-03-25 3153/week @ 2024-04-01 3446/week @ 2024-04-08 3115/week @ 2024-04-15 2897/week @ 2024-04-22 2218/week @ 2024-04-29 2650/week @ 2024-05-06 2206/week @ 2024-05-13 2227/week @ 2024-05-20 2936/week @ 2024-05-27 1916/week @ 2024-06-03 2117/week @ 2024-06-10

9,290 downloads per month
Used in 24 crates (12 directly)

MIT/Apache

24KB
518 lines

svgbobdoc

docs.rs

This crate provides a procedural macro that renders ASCII diagrams in doc comments as SVG images using svgbob.

Requires Rust version 1.54 or later or equivalent nightly builds.

Usage

Add the following line to Cargo.toml.

[dependencies]
svgbobdoc = { version = "0.2", features = ["enable"] }

transform!

Wrap doc comments with #[doc = transform!(...)]. Use svgbob code blocks to write ASCII diagrams.

#[doc = svgbobdoc::transform!(
/// Some structure.
///
/// ```svgbob
///  .--------------------.
///  | Diagrams here      |
///  `--------------------'
/// ```
)]
pub struct TestStruct {}

See the example directory for a complete example.

Tips

  • Using this macro increases the compilation time. The enable Cargo feature can be used to turn off the transformation and the compilation of most dependent packages.

  • A link reference definition ([label]: data:...) can be generated by providing a link label in a code fence header as in ~~~svgbob,[label].

License: MIT/Apache-2.0

Dependencies

~1.6–3MB
~64K SLoC