pretty_print/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2#![deny(missing_debug_implementations, missing_copy_implementations)]
3#![warn(missing_docs, rustdoc::missing_crate_level_docs)]
4#![doc = include_str!("../readme.md")]
5#![doc(html_logo_url = "https://raw.githubusercontent.com/oovm/shape-rs/dev/projects/images/Trapezohedron.svg")]
6#![doc(html_favicon_url = "https://raw.githubusercontent.com/oovm/shape-rs/dev/projects/images/Trapezohedron.svg")]
7
8extern crate alloc;
9extern crate core;
10
11pub mod helpers;
12mod providers;
13mod render;
14mod traits;
15mod tree;
16
17pub use self::render::{
18    write_fmt::{BufferWrite, FmtWrite},
19    PrettyFormatter, Render, RenderAnnotated,
20};
21#[cfg(feature = "std")]
22pub use crate::render::write_io::{IoWrite, TerminalWriter};
23pub use crate::{
24    providers::PrettyProvider,
25    traits::{printer::PrettyPrint, PrettyBuilder},
26    tree::PrettyTree,
27};
28pub use color_ansi::*;
29
30/// Concatenates a number of documents (or values that can be converted into a document via the
31/// `Pretty` trait, like `&str`)
32///
33/// ```
34/// use pretty_print::docs;
35/// let doc =
36///     docs!["let", arena.softline(), "x", arena.softline(), "=", arena.softline(), Some("123"),];
37/// assert_eq!(doc.1.pretty(80).to_string(), "let x = 123");
38/// ```
39#[macro_export]
40macro_rules! docs {
41    ($alloc: expr, $first: expr $(,)?) => {
42        $crate::Pretty::pretty($first, $alloc)
43    };
44    ($alloc: expr, $first: expr $(, $rest: expr)+ $(,)?) => {{
45        let mut doc = $crate::Pretty::pretty($first, $alloc);
46        $(
47            doc = doc.append($rest);
48        )*
49        doc
50    }}
51}