diff options
author | Andrzej Ratajczak <andrzej.ratajczak98@gmail.com> | 2020-08-13 14:18:45 +0200 |
---|---|---|
committer | Sebastian Sellmair <34319766+sellmair@users.noreply.github.com> | 2020-08-17 11:53:29 +0200 |
commit | 24710663084b0ccd964a2b8a3e0b1dacd63dac43 (patch) | |
tree | 2f09197b8388362e375ddcd6694a6f3e6a2d8116 /plugins | |
parent | 9a074919f4c0258cf2bf0cb61238a6005844e20b (diff) | |
download | dokka-24710663084b0ccd964a2b8a3e0b1dacd63dac43.tar.gz dokka-24710663084b0ccd964a2b8a3e0b1dacd63dac43.tar.bz2 dokka-24710663084b0ccd964a2b8a3e0b1dacd63dac43.zip |
Add generic typealiases proper parsing and some tests
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt | 3 | ||||
-rw-r--r-- | plugins/base/src/test/kotlin/signatures/SignatureTest.kt | 104 |
2 files changed, 106 insertions, 1 deletions
diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index 383a3715..dac88768 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -501,7 +501,8 @@ private class DokkaDescriptorVisitor( underlyingType = underlyingType.toBound().toSourceSetDependent(), visibility = visibility.toDokkaVisibility().toSourceSetDependent(), documentation = resolveDescriptorData(), - sourceSets = setOf(sourceSet) + sourceSets = setOf(sourceSet), + generics = descriptor.declaredTypeParameters.map { it.toTypeParameter() } ) } diff --git a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt index 421dd97f..dd3d85c1 100644 --- a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt +++ b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt @@ -425,6 +425,110 @@ class SignatureTest : AbstractCoreTest() { } } + @Test + fun `plain typealias of plain class`() { + + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + moduleName = "test" + name = "common" + sourceRoots = listOf("src/main/kotlin/common/Test.kt") + } + } + } + + val writerPlugin = TestOutputWriterPlugin() + + testInline( + """ + |/src/main/kotlin/common/Test.kt + |package example + | + |typealias PlainTypealias = Int + | + """.trimMargin(), + configuration, + pluginOverrides = listOf(writerPlugin) + ) { + renderingStage = { _, _ -> + writerPlugin.writer.renderedContent("test/example.html").signature().first().match( + "typealias ", A("PlainTypealias"), " = ", A("Int"), Span() + ) + } + } + } + + @Test + fun `plain typealias of generic class`() { + + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + moduleName = "test" + name = "common" + sourceRoots = listOf("src/main/kotlin/common/Test.kt") + } + } + } + + val writerPlugin = TestOutputWriterPlugin() + + testInline( + """ + |/src/main/kotlin/common/Test.kt + |package example + | + |typealias PlainTypealias = Comparable<Int> + | + """.trimMargin(), + configuration, + pluginOverrides = listOf(writerPlugin) + ) { + renderingStage = { _, _ -> + writerPlugin.writer.renderedContent("test/example.html").signature().first().match( + "typealias ", A("PlainTypealias"), " = ", A("Comparable"), + "<", A("Int"), ">", Span() + ) + } + } + } + + @Test + fun `typealias with generics params`() { + + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + moduleName = "test" + name = "common" + sourceRoots = listOf("src/main/kotlin/common/Test.kt") + } + } + } + + val writerPlugin = TestOutputWriterPlugin() + + testInline( + """ + |/src/main/kotlin/common/Test.kt + |package example + | + |typealias GenericTypealias<T> = Comparable<T> + | + """.trimMargin(), + configuration, + pluginOverrides = listOf(writerPlugin) + ) { + renderingStage = { _, _ -> + writerPlugin.writer.renderedContent("test/example.html").signature().first().match( + "typealias ", A("GenericTypealias"), "<", A("T"), "> = ", A("Comparable"), + "<", A("T"), ">", Span() + ) + } + } + } + private fun TestOutputWriter.renderedContent(path: String = "root/example.html") = contents.getValue(path).let { Jsoup.parse(it) }.select("#content") .single() |