Skip to content

PrettyPrinter

class PrettyPrinter(val indentSize: Int = 2) : Appendable

Constructors

PrettyPrinter

constructor(indentSize: Int = 2)

Properties

indentSize

Functions

append

open override fun append(nullableSeq: CharSequence?): Appendable
open override fun append(
    nullableSeq: CharSequence?, 
    start: Int, 
    end: Int
): Appendable
open override fun append(c: Char): Appendable

checkIfPrinted

fun checkIfPrinted(render: () -> Unit): Boolean

invoke

inline operator fun invoke(print: PrettyPrinter.() -> Unit)

printCharIfNotThere

printCollection

inline fun <T> printCollection(
    collection: Iterable<T>, 
    separator: String = ", ", 
    prefix: String = "", 
    postfix: String = "", 
    renderItem: PrettyPrinter.(T) -> Unit
)

printCollectionIfNotEmpty

inline fun <T> printCollectionIfNotEmpty(
    collection: Iterable<T>, 
    separator: String = ", ", 
    prefix: String = "", 
    postfix: String = "", 
    renderItem: PrettyPrinter.(T) -> Unit
)

separated

fun String.separated(p1: () -> Unit, p2: () -> Unit)
fun String.separated(
    p1: () -> Unit, 
    p2: () -> Unit, 
    p3: () -> Unit
)
fun String.separated(
    p1: () -> Unit, 
    p2: () -> Unit, 
    p3: () -> Unit, 
    p4: () -> Unit
)
fun String.separated(
    p1: () -> Unit, 
    p2: () -> Unit, 
    p3: () -> Unit, 
    p4: () -> Unit, 
    p5: () -> Unit
)

toString

open override fun toString(): String

withIndent

fun withIndent(block: PrettyPrinter.() -> Unit)

withIndentInBraces

withIndentInSquareBrackets

withIndents

fun withIndents(indentCount: Int, block: PrettyPrinter.() -> Unit)

withIndentWrapped

fun withIndentWrapped(
    before: String, 
    after: String, 
    block: PrettyPrinter.() -> Unit
)

withPrefix

fun withPrefix(prefix: String, print: () -> Unit)

withSuffix

fun withSuffix(suffix: String, p1: () -> Unit)