shield_maker/lib.rs
1/*!
2A simple badge generator in shields.io style, for Rust.
3
4### Features
5- Simple, bare-minimum API.
6- Plastic, Flat, and Flat-Squared styles
7- SVG output
8
9### Example
10
11```rust
12use std::fs;
13use std::io;
14use ab_glyph::FontArc;
15use shield_maker::{Renderer, Metadata, Style, FontFamily};
16
17fn main() -> io::Result<()> {
18 let font_bytes = fs::read("tests/resources/DejaVuSans.ttf")
19 .expect("could not read DejaVuSans.ttf");
20 let font = FontArc::try_from_vec(font_bytes)
21 .expect("could not parse DejaVuSans.ttf");
22
23 let meta = &Metadata {
24 style: Style::Plastic,
25 label: "coverage",
26 message: "100%",
27 font,
28 font_family: FontFamily::Default,
29 label_color: None,
30 color: None,
31 };
32
33 let output = Renderer::render(meta);
34 let raw_plastic_badge = fs::read("tests/resources/plastic_badge.svg")
35 .expect("could not read plastic_badge.svg");
36 let plastic_badge: String = String::from_utf8(raw_plastic_badge)
37 .expect("failed converting plastic_badge.svg to String")
38 .trim()
39 .into();
40 assert_eq!(plastic_badge, output);
41
42 Ok(())
43}
44```
45 */
46
47#![forbid(unsafe_code)]
48#![warn(missing_docs)]
49#![warn(missing_copy_implementations)]
50
51mod color;
52mod xml;
53mod flat_square_style;
54mod flat_style;
55mod plastic_style;
56
57mod badge;
58pub use badge::{*};