diff options
author | Marcin Aman <marcin.aman@gmail.com> | 2021-07-28 09:14:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-28 09:14:38 +0200 |
commit | 2cd95b0828518dde751d039f4456dcf93e04dfc1 (patch) | |
tree | bf63fa90f16a53b4af01d29a9494f4e5ad531bd7 /plugins/base/src/test/kotlin/content/receiver/ContentForReceiverTest.kt | |
parent | 79cf537a1d0d5864e23af754836e48d13a5d722f (diff) | |
download | dokka-2cd95b0828518dde751d039f4456dcf93e04dfc1.tar.gz dokka-2cd95b0828518dde751d039f4456dcf93e04dfc1.tar.bz2 dokka-2cd95b0828518dde751d039f4456dcf93e04dfc1.zip |
Missing receiver docs (#2026)
Diffstat (limited to 'plugins/base/src/test/kotlin/content/receiver/ContentForReceiverTest.kt')
-rw-r--r-- | plugins/base/src/test/kotlin/content/receiver/ContentForReceiverTest.kt | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/plugins/base/src/test/kotlin/content/receiver/ContentForReceiverTest.kt b/plugins/base/src/test/kotlin/content/receiver/ContentForReceiverTest.kt new file mode 100644 index 00000000..e566320c --- /dev/null +++ b/plugins/base/src/test/kotlin/content/receiver/ContentForReceiverTest.kt @@ -0,0 +1,57 @@ +package content.receiver + +import junit.framework.Assert.assertEquals +import junit.framework.Assert.assertNotNull +import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest +import org.jetbrains.dokka.model.dfs +import org.jetbrains.dokka.model.doc.Receiver +import org.jetbrains.dokka.model.doc.Text +import org.jetbrains.dokka.pages.ContentHeader +import org.jetbrains.dokka.pages.ContentText +import org.jetbrains.dokka.pages.MemberPageNode +import org.junit.jupiter.api.Test +import utils.docs + +class ContentForReceiverTest: BaseAbstractTest() { + private val testConfiguration = dokkaConfiguration { + sourceSets { + sourceSet { + sourceRoots = listOf("src/") + analysisPlatform = "jvm" + } + } + } + + @Test + fun `should have docs for receiver`(){ + testInline( + """ + |/src/main/kotlin/test/source.kt + |package test + |/** + | * docs + | * @receiver docs for string + | */ + |fun String.asd2(): String = this + """.trimIndent(), + testConfiguration + ){ + documentablesTransformationStage = { module -> + with(module.packages.flatMap { it.functions }.first()){ + val receiver = docs().firstOrNull { it is Receiver } + assertNotNull(receiver) + val content = receiver?.dfs { it is Text } as Text + assertEquals("docs for string", content.body) + } + } + pagesTransformationStage = { rootPageNode -> + val functionPage = rootPageNode.dfs { it is MemberPageNode } as MemberPageNode + val header = functionPage.content.dfs { it is ContentHeader && it.children.firstOrNull() is ContentText } + val text = functionPage.content.dfs { it is ContentText && it.text == "docs for string" } + + assertNotNull(header) + assertNotNull(text) + } + } + } +}
\ No newline at end of file |