From d955443b21f834cf77f40ce5da0641323543d866 Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Sun, 11 Apr 2021 18:43:24 +0100 Subject: [PATCH] Add citation to cc.pretty ust to look extra pretentious. --- .../lua/rom/modules/main/cc/pretty.lua | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/pretty.lua b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/pretty.lua index 9a3aa7b0a..f202c204e 100644 --- a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/pretty.lua +++ b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/pretty.lua @@ -1,23 +1,28 @@ ---- Provides a "pretty printer", for rendering data structures in an --- aesthetically pleasing manner. --- --- In order to display something using @{cc.pretty}, you build up a series of --- @{Doc|documents}. These behave a little bit like strings; you can concatenate --- them together and then print them to the screen. --- --- However, documents also allow you to control how they should be printed. There --- are several functions (such as @{nest} and @{group}) which allow you to control --- the "layout" of the document. When you come to display the document, the 'best' --- (most compact) layout is used. --- --- @module cc.pretty --- @usage Print a table to the terminal --- local pretty = require "cc.pretty" --- pretty.print(pretty.pretty({ 1, 2, 3 })) --- --- @usage Build a custom document and display it --- local pretty = require "cc.pretty" --- pretty.print(pretty.group(pretty.text("hello") .. pretty.space_line .. pretty.text("world"))) +--[[- Provides a "pretty printer", for rendering data structures in an +aesthetically pleasing manner. + +In order to display something using @{cc.pretty}, you build up a series of +@{Doc|documents}. These behave a little bit like strings; you can concatenate +them together and then print them to the screen. + +However, documents also allow you to control how they should be printed. There +are several functions (such as @{nest} and @{group}) which allow you to control +the "layout" of the document. When you come to display the document, the 'best' +(most compact) layout is used. + +The structure of this module is based on [A Prettier Printer][prettier]. + +[prettier]: https://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf "A Prettier Printer" + +@module cc.pretty +@usage Print a table to the terminal + local pretty = require "cc.pretty" + pretty.print(pretty.pretty({ 1, 2, 3 })) + +@usage Build a custom document and display it + local pretty = require "cc.pretty" + pretty.print(pretty.group(pretty.text("hello") .. pretty.space_line .. pretty.text("world"))) +]] local expect = require "cc.expect" local expect, field = expect.expect, expect.field