https://github.com/yvt/svgbobdoc
Rust procedural macro that renders ASCII diagrams in doc comments as SVG images.
https://github.com/yvt/svgbobdoc
Last synced: over 1 year ago
JSON representation
Rust procedural macro that renders ASCII diagrams in doc comments as SVG images.
- Host: GitHub
- URL: https://github.com/yvt/svgbobdoc
- Owner: yvt
- License: apache-2.0
- Created: 2019-05-29T06:13:04.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2024-11-24T02:35:44.000Z (over 1 year ago)
- Last Synced: 2025-04-02T09:08:40.378Z (over 1 year ago)
- Language: Rust
- Homepage:
- Size: 175 KB
- Stars: 20
- Watchers: 3
- Forks: 3
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# svgbobdoc
[
](https://docs.rs/svgbobdoc/)
This crate provides a procedural macro that renders
ASCII diagrams in doc comments as SVG images using [`svgbob`].
*Requires Rust version 1.73 or later or equivalent nightly builds.*
[`svgbob`]: https://github.com/ivanceras/svgbob

## Usage
Add the following line to `Cargo.toml`.
```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