diff --git a/README.md b/README.md index 31d848c..0d33248 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # PPrint for Kotlin -This is a port of Li Haoyi's excellent Scala pretty-printing library into Kotlin [print](https://github.com/com-lihaoyi/PPrint). +This is a port of Li Haoyi's excellent Scala pretty-printing library into Kotlin [PPrint](https://github.com/com-lihaoyi/PPrint). (As well as Li Haoyi's excellent Ansi-Formatting library Fansi!) ## Usage @@ -83,7 +83,31 @@ println(pprint(p)) ## +## Removing Field Names + +By default pprint will print the field names of data classes. You can remove these by using `showFieldNames = false`: +```kotlin +val p = Person(Name("Joe", "Bloggs"), 42) +println(pprint(p, showFieldNames = false)) +``` + +For larger ADTs this dramatically reduces the amount of output and often improves the readability. + +## User-controlled Width + +Another nice feature of PPrint is that it can print data classes with a user-controlled width. + +```kotlin +println(pprint(p, showFieldNames = false, defaultWidth = 30)) // Narrow +``` + + +```kotlin +println(pprint(p, showFieldNames = false, defaultWidth = 100)) // Wide +``` + +## ## Infinite Sequences @@ -119,17 +143,6 @@ val p = Person(Name("Joe", "Bloggs"), 42) println(pprint(p).plainText) ``` -## Removing Field Names - -By default pprint will print the field names of data classes. You can remove these by using `showFieldNames = false`: - -```kotlin -val p = Person(Name("Joe", "Bloggs"), 42) -println(pprint(p, showFieldNames = false)) -``` - -For larger ADTs this dramatically reduces the amount of output and often improves the readability. - ## Extending PPrint TODO