diff options
Diffstat (limited to 'test/src/TestAPI.kt')
-rw-r--r-- | test/src/TestAPI.kt | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/src/TestAPI.kt b/test/src/TestAPI.kt index 27d02710..309654e5 100644 --- a/test/src/TestAPI.kt +++ b/test/src/TestAPI.kt @@ -38,3 +38,30 @@ public fun verifyModel(vararg files: String, verifier: (DocumentationModule) -> Disposer.dispose(environment) } +fun StringBuilder.appendChildren(node: ContentNode) : StringBuilder { + for (child in node.children) { + val childText = child.toTestString() + append(childText) + } + return this +} + +fun StringBuilder.appendNode(node: ContentNode) : StringBuilder { + when (node) { + is ContentText -> { + append(node.text) + } + is ContentEmphasis -> append("*").appendChildren(node).append("*") + else -> { + appendChildren(node) + } + } + return this +} + +fun ContentNode.toTestString(): String { + val node = this + return StringBuilder { + appendNode(node) + }.toString() +} |