diff options
author | Andrzej Ratajczak <andrzej.ratajczak98@gmail.com> | 2020-02-05 13:54:04 +0100 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-02-12 14:29:06 +0100 |
commit | 18e28d080792d3f805d8e3c787675712d6b9b7ce (patch) | |
tree | 415aa35b01e58a61c994a2f5cd823fa37d204df7 /testApi/src/main/kotlin | |
parent | 199b69db4c1cb2cd90a2a190479082150235faf4 (diff) | |
download | dokka-18e28d080792d3f805d8e3c787675712d6b9b7ce.tar.gz dokka-18e28d080792d3f805d8e3c787675712d6b9b7ce.tar.bz2 dokka-18e28d080792d3f805d8e3c787675712d6b9b7ce.zip |
Implements tests for MarkdownParser and fixes some bugs related to its
Diffstat (limited to 'testApi/src/main/kotlin')
-rw-r--r-- | testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt b/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt index b8817918..f906755a 100644 --- a/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt +++ b/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt @@ -2,12 +2,15 @@ package testApi.testRunner import org.jetbrains.dokka.* import org.jetbrains.dokka.model.Module +import org.jetbrains.dokka.model.Package +import org.jetbrains.dokka.model.doc.DocumentationNode import org.jetbrains.dokka.pages.ModulePageNode import org.jetbrains.dokka.pages.PlatformData import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.DokkaPlugin import org.jetbrains.dokka.utilities.DokkaConsoleLogger +import org.junit.Assert import org.junit.rules.TemporaryFolder import java.io.File import java.nio.charset.Charset @@ -200,6 +203,48 @@ abstract class AbstractCoreTest { } } +abstract class AbstractKDocTest : 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) + ) + } + } + } +} + + data class TestMethods( val analysisSetupStage: (Map<PlatformData, EnvironmentAndFacade>) -> Unit, val pluginsSetupStage: (DokkaContext) -> Unit, |