Skip to main content

logparse_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 text;
15mod traits;
16mod tree;
17
18pub use self::render::{
19    PrettyFormatter, Render, RenderAnnotated,
20    write_fmt::{BufferWrite, FmtWrite},
21};
22#[cfg(feature = "std")]
23pub use crate::render::write_io::{IoWrite, TerminalWriter, VecWrite};
24pub use crate::{
25    providers::PrettyProvider,
26    traits::{PrettyBuilder, printer::PrettyPrint},
27    tree::PrettyTree,
28};
29pub use color_ansi::*;
30pub use text::Text;
31
32/// Concatenates a number of documents (or values that can be converted into a document via the
33/// `Pretty` trait, like `&str`)
34///
35/// ```
36/// use pretty_print::docs;
37/// let doc =
38///     docs!["let", arena.softline(), "x", arena.softline(), "=", arena.softline(), Some("123"),];
39/// assert_eq!(doc.1.pretty(80).to_string(), "let x = 123");
40/// ```
41#[macro_export]
42macro_rules! docs {
43    ($alloc: expr, $first: expr $(,)?) => {
44        $crate::Pretty::pretty($first, $alloc)
45    };
46    ($alloc: expr, $first: expr $(, $rest: expr)+ $(,)?) => {{
47        let mut doc = $crate::Pretty::pretty($first, $alloc);
48        $(
49            doc = doc.append($rest);
50        )*
51        doc
52    }}
53}