diff options
author | vmishenev <vad-mishenev@yandex.ru> | 2021-10-29 01:36:14 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-29 01:36:14 +0300 |
commit | d4e255b149c8c80cf13df9e10b128e892bb0d338 (patch) | |
tree | 9251e41d70d0e7b56f4252bb9f59b76358c375b5 | |
parent | 7dd0867a0f921b2ae06537c06de358949b42fbda (diff) | |
download | dokka-d4e255b149c8c80cf13df9e10b128e892bb0d338.tar.gz dokka-d4e255b149c8c80cf13df9e10b128e892bb0d338.tar.bz2 dokka-d4e255b149c8c80cf13df9e10b128e892bb0d338.zip |
Fix names of nested inheritors (#2188)
-rw-r--r-- | plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt | 2 | ||||
-rw-r--r-- | plugins/base/src/test/kotlin/renderers/html/CoverPageTest.kt | 47 |
2 files changed, 48 insertions, 1 deletions
diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index 300e0926..332a0663 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -197,7 +197,7 @@ open class DefaultPageCreator( }), children = map.entries.flatMap { entry -> entry.value.map { Pair(entry.key, it) } } .groupBy({ it.second }, { it.first }).map { (classlike, platforms) -> - val label = classlike.classNames?.substringBeforeLast(".") ?: classlike.toString() + val label = classlike.classNames?.substringAfterLast(".") ?: classlike.toString() .also { logger.warn("No class name found for DRI $classlike") } buildGroup( setOf(classlike), diff --git a/plugins/base/src/test/kotlin/renderers/html/CoverPageTest.kt b/plugins/base/src/test/kotlin/renderers/html/CoverPageTest.kt new file mode 100644 index 00000000..0e1f53ec --- /dev/null +++ b/plugins/base/src/test/kotlin/renderers/html/CoverPageTest.kt @@ -0,0 +1,47 @@ +package renderers.html + +import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest +import org.junit.jupiter.api.Test +import signatures.renderedContent +import utils.TestOutputWriterPlugin +import kotlin.test.assertEquals + +class CoverPageTest : BaseAbstractTest() { + + private val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + sourceRoots = listOf("src/") + classpath = listOf(commonStdlibPath!!) + externalDocumentationLinks = listOf(stdlibExternalDocumentationLink) + } + } + } + + @Test + fun `names of nested inheritors`() { + val source = """ + |/src/main/kotlin/test/Test.kt + |package example + | + | sealed class Result{ + | class Success(): Result() + | class Failed(): Result() + | } + """ + val writerPlugin = TestOutputWriterPlugin() + + testInline( + source, + configuration, + pluginOverrides = listOf(writerPlugin) + ) { + renderingStage = { _, _ -> + val content = writerPlugin.writer.renderedContent("root/example/-result/index.html") + val tableInheritors = content.select("div.table[data-togglable=Inheritors]").single() + assertEquals(tableInheritors.getElementsContainingOwnText("Failed").singleOrNull()?.tagName(), "a") + assertEquals(tableInheritors.getElementsContainingOwnText("Success").singleOrNull()?.tagName(), "a") + } + } + } +}
\ No newline at end of file |