From 12a386bb7185f862a1cbd831e6856c4235953833 Mon Sep 17 00:00:00 2001 From: Vadim Mishenev Date: Fri, 30 Jun 2023 16:44:20 +0300 Subject: Generate dedicated pages for typealiases (#3051) --- .../content/functions/ContentForBriefTest.kt | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'plugins/base/src/test/kotlin/content/functions') diff --git a/plugins/base/src/test/kotlin/content/functions/ContentForBriefTest.kt b/plugins/base/src/test/kotlin/content/functions/ContentForBriefTest.kt index f86506af..c09a0e4d 100644 --- a/plugins/base/src/test/kotlin/content/functions/ContentForBriefTest.kt +++ b/plugins/base/src/test/kotlin/content/functions/ContentForBriefTest.kt @@ -4,6 +4,7 @@ import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.links.TypeConstructor import org.jetbrains.dokka.model.DClass +import org.jetbrains.dokka.model.DPackage import org.jetbrains.dokka.model.dfs import org.jetbrains.dokka.pages.* import org.junit.jupiter.api.Assertions.assertEquals @@ -131,6 +132,32 @@ class ContentForBriefTest : BaseAbstractTest() { } } + @Test + fun `brief should work for typealias`() { + testInline( + """ + |/src/main/kotlin/test/source.kt + |package test + | + |/** + |* This is an example of html + |* + |* This is definitely not a brief + |*/ + |typealias A = Int + """.trimIndent(), + testConfiguration + ) { + pagesTransformationStage = { module -> + val functionBriefDocs = module.singleTypeAliasesDescription("test") + + assertEquals( + "This is an example of html", + functionBriefDocs.children.joinToString("") { (it as ContentText).text }) + } + } + } + @Test fun `brief for functions should work with html`() { testInline( @@ -344,4 +371,14 @@ class ContentForBriefTest : BaseAbstractTest() { val function = functionsTable.children.first() return function.dfs { it is ContentGroup && it.dci.kind == ContentKind.Comment && it.children.all { it is ContentText } } as ContentGroup } + private fun RootPageNode.singleTypeAliasesDescription(packageName: String): ContentGroup { + val packagePage = + dfs { it.name == packageName && (it as WithDocumentables).documentables.firstOrNull() is DPackage } as ContentPage + val contentTable = + packagePage.content.dfs { it is ContentTable && it.dci.kind == ContentKind.Classlikes } as ContentTable + + assertEquals(1, contentTable.children.size) + val row = contentTable.children.first() + return row.dfs { it is ContentGroup && it.dci.kind == ContentKind.Comment && it.children.all { it is ContentText } } as ContentGroup + } } \ No newline at end of file -- cgit