pretty print module for the jvm
Branch: master
Clone or download
snowe2010 Add ASCII word wrap function. (#5)
currently only supports splitting on spaces, it searches for a locally
optimal line break and therefore will result in lines at the end that
could be much shorter than earlier lines.

there is no emergency mode for wrapping an otherwise unwrappable string,
for example a long string with no spaces in it.
Latest commit 0dbfb8a Feb 13, 2019

README.md

Build Status Download codecov

Pretty Print - pp

adds a single method pp to pretty print any java or kotlin object.

Examples

pp(
    NestedObjectWithCollection(
        listOf(NestedSmallObject(SmallObject("a", 1)))
    )
)

prints

NestedObjectWithCollection(
  coll = [
           NestedSmallObject(
             smallObject = SmallObject(
               field1 = a
               field2 = 1
             )
           )
         ]
)

Cyclic references

data class SmallCyclicalObject1(
    val c: SmallCyclicalObject2? = null
)
data class SmallCyclicalObject2(
    val c: SmallCyclicalObject1? = null
)
val sco1 = SmallCyclicalObject1()
val sco2 = SmallCyclicalObject2(sco1)
sco1.c = sco2
pp(sco1)

prints

ObjectWithMap(
  map = {
          1 -> ObjectContainingObjectWithMap(
            objectWithMap = cyclic reference detected for 775386112
          )
        }
)[$id=775386112]

ToDo

  • implement cycle detection
  • test nullability cases (requires cycle detection)
  • allow printing of java* classes (requires cycle detection)