aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest3.kt
blob: 6c9c351f405732586e17c38c390d8c3fffc3d38a (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
49
50
51
52
53
54
package transformers

import org.jetbrains.dokka.base.transformers.documentables.ModuleAndPackageDocumentationReader
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.utilities.DokkaConsoleLogger
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import testApi.testRunner.TestDokkaConfigurationBuilder
import testApi.testRunner.dPackage
import kotlin.test.assertEquals

class ContextModuleAndPackageDocumentationReaderTest3 : AbstractContextModuleAndPackageDocumentationReaderTest() {

    private val include by lazy { temporaryDirectory.resolve("include.md").toFile() }

    @BeforeEach
    fun materializeInclude() {
        include.writeText(
            """
            # Package
            This is the root package
            
            # Package [root]
            This is also the root package
            """.trimIndent()
        )
    }

    private val configurationBuilder = TestDokkaConfigurationBuilder()

    private val sourceSet by configurationBuilder.sourceSet {
        includes = listOf(include.canonicalPath)
    }

    private val context by lazy {
        DokkaContext.create(
            configuration = configurationBuilder.build(),
            logger = DokkaConsoleLogger(),
            pluginOverrides = emptyList()
        )
    }

    private val reader by lazy { ModuleAndPackageDocumentationReader(context) }


    @Test
    fun `root package is matched by empty string and the root keyword`() {
        val documentation = reader[dPackage(DRI(""), sourceSets = setOf(sourceSet))]
        assertEquals(
            listOf("This is the root package", "This is also the root package"), documentation.texts
        )
    }
}