#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

#20 in #figure

Download history 3363/week @ 2024-07-21 3716/week @ 2024-07-28 3681/week @ 2024-08-04 3023/week @ 2024-08-11 2391/week @ 2024-08-18 2788/week @ 2024-08-25 2424/week @ 2024-09-01 4497/week @ 2024-09-08 3516/week @ 2024-09-15 4240/week @ 2024-09-22 4839/week @ 2024-09-29 4500/week @ 2024-10-06 4938/week @ 2024-10-13 5735/week @ 2024-10-20 3735/week @ 2024-10-27 3657/week @ 2024-11-03

18,268 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

~2.5–4.5MB
~84K SLoC