#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

#906 in Text processing

Download history 1587/week @ 2023-11-24 1523/week @ 2023-12-01 1372/week @ 2023-12-08 1058/week @ 2023-12-15 1053/week @ 2023-12-22 1366/week @ 2023-12-29 1937/week @ 2024-01-05 1953/week @ 2024-01-12 2811/week @ 2024-01-19 2514/week @ 2024-01-26 1794/week @ 2024-02-02 1730/week @ 2024-02-09 1984/week @ 2024-02-16 3527/week @ 2024-02-23 2242/week @ 2024-03-01 2074/week @ 2024-03-08

10,090 downloads per month
Used in 24 crates (11 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.4–2.9MB
~62K SLoC