diff options
Diffstat (limited to 'plugins/base/src/test/kotlin/markdown/KDocTest.kt')
-rw-r--r-- | plugins/base/src/test/kotlin/markdown/KDocTest.kt | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/plugins/base/src/test/kotlin/markdown/KDocTest.kt b/plugins/base/src/test/kotlin/markdown/KDocTest.kt new file mode 100644 index 00000000..c58c4e30 --- /dev/null +++ b/plugins/base/src/test/kotlin/markdown/KDocTest.kt @@ -0,0 +1,48 @@ +package markdown + +import org.jetbrains.dokka.model.Package +import org.jetbrains.dokka.model.doc.DocumentationNode +import org.jetbrains.dokka.pages.ModulePageNode +import org.junit.Assert +import testApi.testRunner.AbstractCoreTest + +open class KDocTest : AbstractCoreTest() { + + private val configuration = dokkaConfiguration { + passes { + pass { + sourceRoots = listOf("src/main/kotlin/example/Test.kt") + } + } + } + + private fun interpolateKdoc(kdoc: String) = """ + |/src/main/kotlin/example/Test.kt + |package example + | /** + ${kdoc.split("\n").joinToString("") { "| *$it\n" } } + | */ + |class Test + """.trimMargin() + + private fun actualDocumentationNode(modulePageNode: ModulePageNode) = + (modulePageNode.documentable?.children?.first() as Package) + .classlikes.first() + .platformInfo.first() + .documentationNode + + + protected fun executeTest(kdoc: String, expectedDocumentationNode: DocumentationNode) { + testInline( + interpolateKdoc(kdoc), + configuration + ) { + pagesGenerationStage = { + Assert.assertEquals( + expectedDocumentationNode, + actualDocumentationNode(it) + ) + } + } + } +}
\ No newline at end of file |