Giter Club home page Giter Club logo

prettyprint.jl-8162dcfd-2161-5ef2-ae6c-7681170c5f98's Introduction

PrettyPrint

Build Status Codecov

Install

pkg> add https://github.com/thautwarm/PrettyPrint.jl#master

Basic Usage

using PrettyPrint

struct S1
    i :: Int
    f :: Float64
end

struct S2
    s  :: Vector{String}
    s1 :: S1
end

data = S2(
    ["114514", "as we can"],
    S1(42, 9.96)
)
pprint(data) # or print(pformat(data))

produces

S2(
  s=[
    "114514",
    "as we cam",
  ],
  s1=S1(
    i=42,
    f=9.96,
  ),
)

Pretty print extension for any other type

using PrettyPrint
struct Account
    username :: String
    password :: String
end

@info :before_extension
pprint(
        [Account("van", "gd"), Account("thautwarm", "996icu")]
)
println()
PrettyPrint.pprint_impl(io, account::Account, indent::Int, newline::Bool) = print(io, "Account($(account.username))")

@info :after_extension
pprint(
        [Account("van", "gd"), Account("thautwarm", "996icu")]
)
println()

produces

[ Info: before_extension
[
  Account(
    username="van",
    password="gd",
  ),
  Account(
    username="thautwarm",
    password="996icu",
  ),
]
[ Info: after_extension
[
  Account(van),
  Account(thautwarm),
]

Built-in Supported Datatypes

  1. Vector
  2. Tuple
  3. Set
  4. String
  5. Nothing

Any other datatypes are also supported with a default pprint_impl.

prettyprint.jl-8162dcfd-2161-5ef2-ae6c-7681170c5f98's People

Contributors

thautwarm avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.