From 20bbe82b963af3661c760370d6a97b390eb64fef Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Sat, 15 Jul 2017 19:21:21 +0200 Subject: [PATCH] Improved readme. --- README.md | 74 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 54 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 1a0bdb2..2fef184 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,49 @@ # Pretty # -## Introduction - `pretty` is an advanced pretty printer for [Lua](lua.org) aiming primarily for human readability. It does this by looking for patterns in the input data, and creating an output string utilizing and highlighting those patterns. Thus it's a primarily a debugging tool, not a speedy serialization tool. +## Code Example + +Setup is simple, just `pretty = require 'pretty'`, and you're good to go. + +```lua +> print(pretty( { 1, 2, 3 } )) +{ 1, 2, 3 } + +> print(pretty( { hello = 'world', num = 42 } )) +{ + num = 42 + hello = 'world' +} + +> print(pretty( { abs = math.abs, max = math.max, some = function() end } )) +{ + abs = builtin function (x) ... end + max = builtin function (x, ...) ... end + some = function () ... end +} + +> print(pretty( math.abs )) +builtin function (x) + -- math.abs + -- Returns the absolute value of x + + ... +end +``` + +## Motivation + This project is the outcome of my frustration with existing pretty printers, and a desire to expand upon the pretty printer I developed for -[Xenoterm](https://gitfub.space/takunomi/Xenoterm). The default Xenoterm pretty -printer is much simpler than `pretty`, but the enhancements compared to other -pretty printers, inspired me to create `pretty`. See the bottom of the page for -other pretty printers. +[Xenoterm](https://gitfub.space/takunomi/Xenoterm). The original Xenoterm pretty +printer was much simpler than `pretty` - and the current is even simpler - but +the enhancements I make, when compared to other pretty printers, inspired me to +create `pretty`. `pretty` sorts it's priorities like so: @@ -47,23 +77,17 @@ available. * Uses the standard `debug` library to gain information about functions and other advanced structures. -## Readability Methods +## Installation -Here we outline the methods we use when formatting. +TODO -The simplest method is to align keys, equals-sign and values, of a table. Thus -we separate them, and make it easier to distinguish them from each. Compare: +## API Documentation -```lua - bad = { - a = 'hello world', - hello = 'hi' - } - good = { - a = 'hello world', - hello = 'hi' - } -``` +TODO + +## Tests + +TODO ## Performance @@ -118,3 +142,13 @@ options. Lua has a large library of pretty printers and serialization libraries: serialization. Find others at [the lua-users wiki](lua-users.org/wiki/TableSerialization). + +## Contact + +The author is available at `jonjmaa (at) gmail.com`. Be sure to send an email if +you have ideas for improvements, find an issue, or even an unintuitive result. + +## License + +This project is licensed under the BeerWare license - Please see the +TODO[LICENSE.txt][./LICENSE.txt] file for details.