dummy-link

PrettyPrinting

Julia library for optimal formatting of composite data structures on a fixed-width terminal.

Readme

PrettyPrinting.jl

PrettyPrinting is a Julia library for optimal formatting of composite data structures on a fixed-width terminal.

Linux/OSX Build Status Windows Build Status Code Coverage Status Open Issues Documentation MIT License

Quick Start

Install the package using the Julia package manager:

julia> using Pkg
julia> Pkg.add("PrettyPrinting")

To start using the package, import it:

julia> using PrettyPrinting

Use function pprint() to display complex data structures. For example:

julia> data = [(name = "POLICE",
                employees = [(name = "JEFFERY A", position = "SERGEANT", salary = 101442, rate = missing),
                             (name = "NANCY A", position = "POLICE OFFICER", salary = 80016, rate = missing)]),
               (name = "OEMC",
                employees = [(name = "LAKENYA A", position = "CROSSING GUARD", salary = missing, rate = 17.68),
                             (name = "DORIS A", position = "CROSSING GUARD", salary = missing, rate = 19.38)])]
2-element Array{NamedTuple{(:name, :employees),T} where T<:Tuple,1}:
 (name = "POLICE", employees = NamedTuple{(:name, :position, :salary, :rate),Tuple{String,String,Int64,Missing}}[(name = "JEFFERY A", position = "SERGEANT", salary = 101442, rate = missing), (name = "NANCY A", position = "POLICE OFFICER", salary = 80016, rate = missing)])
 (name = "OEMC", employees = NamedTuple{(:name, :position, :salary, :rate),Tuple{String,String,Missing,Float64}}[(name = "LAKENYA A", position = "CROSSING GUARD", salary = missing, rate = 17.68), (name = "DORIS A", position = "CROSSING GUARD", salary = missing, rate = 19.38)])

julia> pprint(data)
[(name = "POLICE",
  employees = [(name = "JEFFERY A",
                position = "SERGEANT",
                salary = 101442,
                rate = missing),
               (name = "NANCY A",
                position = "POLICE OFFICER",
                salary = 80016,
                rate = missing)]),
 (name = "OEMC",
  employees = [(name = "LAKENYA A",
                position = "CROSSING GUARD",
                salary = missing,
                rate = 17.68),
               (name = "DORIS A",
                position = "CROSSING GUARD",
                salary = missing,
                rate = 19.38)])]

PrettyPrinting knows how to format tuples, vectors, and dictionaries. Other data types should implement the function tile() as described in the documentation.

Acknowledgements

The algorithm for finding the optimal layout is based upon Phillip Yelland, A New Approach to Optimal Code Formatting, 2016.

First Commit

11/21/2018

Last Touched

6 days ago

Commits

28 commits

Requires:

Used By: