MCPcopy Index your code
hub / github.com/Marwes/pretty.rs

github.com/Marwes/pretty.rs @v0.12.5

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.12.5 ↗ · + Follow
157 symbols 428 edges 6 files 10 documented · 6% updated 9mo ago★ 17913 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

pretty.rs

build Docs

Pretty printing combinators for Rust

Synopsis

This crate provides functionality for defining pretty printers. It is particularly useful for printing structured recursive data like trees.

The implementation was originally based on Larsen's SML translation (https://github.com/kfl/wpp) of Wadler's Haskell pretty printer (https://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf). It has since been modified in various ways to better fit Rust's programming model. In particular, it uses iteration rather than recursion and provides streaming output.

Documentation

See the generated API documentation here.

Requirements

  1. Rust
  2. Cargo

You can install both with the following:

$ curl -s https://static.rust-lang.org/rustup.sh | sudo sh

See Installation for further details.

Usage

$ cargo build                                          ## build library and binary
$ cargo run --example trees                            ## run the example (pretty trees)
$ cargo run --example colored --features termcolor     ## run the example (pretty colored output)
$ cargo bench                                          ## run benchmarks
$ cargo test                                           ## run tests

Extension points exported contracts — how you extend this code

Pretty (Interface)
Trait for types which can be converted to a `Document` [11 implementers]
src/lib.rs
Render (Interface)
Trait representing the operations necessary to render a document [5 implementers]
src/render.rs
DocAllocator (Interface)
The `DocAllocator` trait abstracts over a type which can allocate (pointers to) `Doc`. [2 implementers]
src/lib.rs
RenderAnnotated (Interface)
Trait representing the operations necessary to write an annotated document. [5 implementers]
src/render.rs
DocPtr (Interface)
(no doc) [1 implementers]
src/lib.rs
DropT (Interface)
(no doc) [1 implementers]
src/lib.rs
StaticDoc (Interface)
(no doc)
src/lib.rs

Core symbols most depended-on inside this repo

append
called by 86
src/lib.rs
clone
called by 20
src/lib.rs
group
called by 20
src/lib.rs
text
called by 16
src/lib.rs
nest
called by 13
src/lib.rs
write_str_all
called by 10
src/render.rs
alloc_cow
called by 9
src/lib.rs
nil
called by 8
src/lib.rs

Shape

Method 80
Function 49
Class 16
Interface 7
Enum 5

Languages

Rust100%

Modules by API surface

src/lib.rs103 symbols
src/render.rs24 symbols
benches/trees.rs13 symbols
examples/trees.rs9 symbols
src/block.rs7 symbols
examples/colored.rs1 symbols

For agents

$ claude mcp add pretty.rs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page