diff options
3 files changed, 109 insertions, 3 deletions
diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt index 33c29ea3..11436fb4 100644 --- a/core/src/main/kotlin/model/Documentable.kt +++ b/core/src/main/kotlin/model/Documentable.kt @@ -333,8 +333,9 @@ data class DTypeAlias( override val documentation: SourceSetDependent<DocumentationNode>, override val expectPresentInSet: DokkaSourceSet?, override val sourceSets: Set<DokkaSourceSet>, - override val extra: PropertyContainer<DTypeAlias> = PropertyContainer.empty() -) : Documentable(), WithType, WithVisibility, WithExtraProperties<DTypeAlias> { + override val extra: PropertyContainer<DTypeAlias> = PropertyContainer.empty(), + override val generics: List<DTypeParameter> +) : Documentable(), WithType, WithVisibility, WithExtraProperties<DTypeAlias>, WithGenerics { override val children: List<Nothing> get() = emptyList() 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() |