blob: c58c4e307977262bcc0701ec7813366291167380 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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)
)
}
}
}
}
|