1
0

Improved readme.

This commit is contained in:
Jon Michael Aanes 2017-07-15 19:21:21 +02:00
parent 346afd61c0
commit 20bbe82b96

View File

@ -1,19 +1,49 @@
# Pretty # # Pretty #
## Introduction
`pretty` is an advanced pretty printer for [Lua](lua.org) aiming primarily for `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 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 creating an output string utilizing and highlighting those patterns. Thus it's
a primarily a debugging tool, not a speedy serialization tool. 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 This project is the outcome of my frustration with existing pretty printers, and
a desire to expand upon the pretty printer I developed for a desire to expand upon the pretty printer I developed for
[Xenoterm](https://gitfub.space/takunomi/Xenoterm). The default Xenoterm pretty [Xenoterm](https://gitfub.space/takunomi/Xenoterm). The original Xenoterm pretty
printer is much simpler than `pretty`, but the enhancements compared to other printer was much simpler than `pretty` - and the current is even simpler - but
pretty printers, inspired me to create `pretty`. See the bottom of the page for the enhancements I make, when compared to other pretty printers, inspired me to
other pretty printers. create `pretty`.
`pretty` sorts it's priorities like so: `pretty` sorts it's priorities like so:
@ -47,23 +77,17 @@ available.
* Uses the standard `debug` library to gain information about functions * Uses the standard `debug` library to gain information about functions
and other advanced structures. 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 ## API Documentation
we separate them, and make it easier to distinguish them from each. Compare:
```lua TODO
bad = {
a = 'hello world', ## Tests
hello = 'hi'
} TODO
good = {
a = 'hello world',
hello = 'hi'
}
```
## Performance ## Performance
@ -118,3 +142,13 @@ options. Lua has a large library of pretty printers and serialization libraries:
serialization. serialization.
Find others at [the lua-users wiki](lua-users.org/wiki/TableSerialization). 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.