1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//! A library for displaying Rust data structures as syntax-highlighted trees.
//!
//! `tree-display` provides a simple derive macro (`#[derive(TreeDisplay)]`)
//! to render any data structure as a beautifully formatted tree in the terminal.
//! Features include syntax highlighting, custom value mapping, and full theming support.
//!
//! ## Quick Start
//! ```no_run
//! use tree_display::{TreeDisplay, Formatter};
//!
//! #[derive(Debug, TreeDisplay)]
//! struct Person {
//! name: String,
//! age: u32,
//! }
//!
//! let person = Person {
//! name: "Alice".to_string(),
//! age: 30,
//! };
//!
//! println!("{}", Formatter::of(&person).format());
//! ```
//!
//! ## Features
//! - **Derive macro**: `#[derive(TreeDisplay)]` for automatic tree generation
//! - **Field attributes**: Control rendering of individual fields:
//! - `#[tree(map)]` - Apply a custom mapper from [`Context`]
//! - `#[tree(ignore)]` - Exclude a field from the tree
//! - `#[tree(label = "...")]` - Override the field's display label
//! - `#[tree(unlabeled)]` - Display the field without a label
//! - **Custom mapping**: Transform values with [`Context`] mappers
//! - **Theming**: Predefined themes (VS Code Dark+, Solarized, etc.)
//! - **Color support**: Optional ANSI color highlighting
//! - **Line styles**: ASCII or Unicode box-drawing characters
//! - **Formatting**: Labels, alignment, and custom content types
use Content;
// Re-export the most commonly used types at root
pub use Colors;
pub use Context;
pub use TreeDisplay;
pub use Formatter;
pub use Graphics;
pub use Theme;
// ──── API ───────────────────────────────────────────────────────────────────────────────────────
/// A type that can be displayed as a tree.
///
/// This trait is automatically implemented by `#[derive(TreeDisplay)]`
/// and is also implemented for many standard library types.
/// A tree node containing content and child subtrees.
///
/// Trees are built from a root node with zero or more child nodes,
/// each of which can have their own children. Nodes can optionally
/// have labels that appear alongside their content.
///
/// ## Example
/// ```
/// use tree_display::{Tree, format::Member};
///
/// let tree = Tree::leaf("root")
/// .labeled(Member::new("label"));
/// ```
// ──── Utility ───────────────────────────────────────────────────────────────────────────────────