#![doc = include_str!("../readme.md")]
#![doc(html_logo_url = "https://raw.githubusercontent.com/oovm/shape-rs/dev/projects/images/Trapezohedron.svg")]
#![doc(html_favicon_url = "https://raw.githubusercontent.com/oovm/shape-rs/dev/projects/images/Trapezohedron.svg")]
extern crate alloc;
mod blocks;
mod providers;
mod traits;
pub use crate::{blocks::k_and_r_bracket::KAndRBracket, providers::PrettyProvider, traits::PrettyPrint};
use core::fmt::{Debug, Formatter};
use std::{borrow::Cow, convert::TryInto, fmt::Display, ops::Add, rc::Rc};
use std::ops::AddAssign;
use termcolor::{ColorSpec, WriteColor};
mod render;
mod tree;
pub use crate::tree::{DocumentTree, DocumentSequence};
pub use self::render::{FmtWrite, IoWrite, Render, RenderAnnotated, terminal::TerminalWriter};
pub struct PrettyFormatter<'a> {
tree: &'a DocumentTree,
width: usize,
}
impl<'a> Display for PrettyFormatter<'a> {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
self.tree.render_fmt(self.width, f)
}
}
#[macro_export]
macro_rules! docs {
($alloc: expr, $first: expr $(,)?) => {
$crate::Pretty::pretty($first, $alloc)
};
($alloc: expr, $first: expr $(, $rest: expr)+ $(,)?) => {{
let mut doc = $crate::Pretty::pretty($first, $alloc);
$(
doc = doc.append($rest);
)*
doc
}}
}
use unicode_segmentation::UnicodeSegmentation;