aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAndrzej Ratajczak <andrzej.ratajczak98@gmail.com>2020-09-17 16:47:07 +0200
committerAndrzej Ratajczak <32793002+BarkingBad@users.noreply.github.com>2020-09-29 14:57:02 +0200
commit26415d91fcf32f0c70af4f9cea9500bca8187b0e (patch)
treea1be8fd6980fc16b0ca2957dd3f2c1d18ed80643 /plugins
parent7e572b6341bc7da3eeed4aef41665097ebad9f35 (diff)
downloaddokka-26415d91fcf32f0c70af4f9cea9500bca8187b0e.tar.gz
dokka-26415d91fcf32f0c70af4f9cea9500bca8187b0e.tar.bz2
dokka-26415d91fcf32f0c70af4f9cea9500bca8187b0e.zip
Add processing of annotations to typealiases
Diffstat (limited to 'plugins')
-rw-r--r--plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt5
-rw-r--r--plugins/base/src/main/kotlin/transformers/documentables/DeprecatedDocumentableFilterTransformer.kt12
-rw-r--r--plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt7
-rw-r--r--plugins/base/src/test/kotlin/signatures/SignatureTest.kt34
4 files changed, 53 insertions, 5 deletions
diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
index d701de04..465f8cb7 100644
--- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
+++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
@@ -279,14 +279,15 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
private fun signature(t: DTypeAlias) =
t.sourceSets.map {
- contentBuilder.contentFor(t, styles = t.stylesIfDeprecated(it), sourceSets = setOf(it)) {
+ contentBuilder.contentFor(t, sourceSets = setOf(it)) {
t.underlyingType.entries.groupBy({ it.value }, { it.key }).map { (type, platforms) ->
+contentBuilder.contentFor(
t,
ContentKind.Symbol,
- setOf(TextStyle.Monospace),
+ setOf(TextStyle.Monospace) + t.stylesIfDeprecated(it),
sourceSets = platforms.toSet()
) {
+ annotationsBlock(t)
text(t.visibility[it]?.takeIf { it !in ignoredVisibilities }?.name?.let { "$it " } ?: "")
processExtraModifiers(t)
text("typealias ")
diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DeprecatedDocumentableFilterTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/DeprecatedDocumentableFilterTransformer.kt
index aab7c6ba..80696cbf 100644
--- a/plugins/base/src/main/kotlin/transformers/documentables/DeprecatedDocumentableFilterTransformer.kt
+++ b/plugins/base/src/main/kotlin/transformers/documentables/DeprecatedDocumentableFilterTransformer.kt
@@ -57,6 +57,10 @@ class DeprecatedDocumentableFilterTransformer(val context: DokkaContext) : PreMe
modified = modified || listModified
list
}
+ val typeAliases = filterTypeAliases(pckg.typealiases).let { (listModified, list) ->
+ modified = modified || listModified
+ list
+ }
when {
!modified -> pckg
else -> {
@@ -64,7 +68,8 @@ class DeprecatedDocumentableFilterTransformer(val context: DokkaContext) : PreMe
pckg.copy(
functions = functions,
properties = properties,
- classlikes = classlikes
+ classlikes = classlikes,
+ typealiases = typeAliases
)
}
}
@@ -95,6 +100,11 @@ class DeprecatedDocumentableFilterTransformer(val context: DokkaContext) : PreMe
)
}
+ private fun filterTypeAliases(typeAliases: List<DTypeAlias>) =
+ typeAliases.filter { it.isAllowedInPackage() }.let {
+ Pair(typeAliases.size != it.size, it)
+ }
+
private fun filterClasslikes(
classlikeList: List<DClasslike>
): Pair<Boolean, List<DClasslike>> {
diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
index 8525586a..68b69719 100644
--- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
@@ -514,7 +514,7 @@ private class DokkaDescriptorVisitor(
sources = descriptor.createSources(),
sourceSets = setOf(sourceSet),
isExpectActual = (isExpect || isActual),
- extra = PropertyContainer.withAll<DFunction>(
+ extra = PropertyContainer.withAll(
descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(),
descriptor.getAnnotations().toSourceSetDependent().toAnnotations()
)
@@ -532,7 +532,10 @@ private class DokkaDescriptorVisitor(
visibility = visibility.toDokkaVisibility().toSourceSetDependent(),
documentation = resolveDescriptorData(),
sourceSets = setOf(sourceSet),
- generics = descriptor.declaredTypeParameters.map { it.toVariantTypeParameter() }
+ generics = descriptor.declaredTypeParameters.map { it.toVariantTypeParameter() },
+ extra = PropertyContainer.withAll(
+ descriptor.getAnnotations().toSourceSetDependent().toAnnotations()
+ )
)
}
diff --git a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
index c6a52271..b8be54aa 100644
--- a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
+++ b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
@@ -401,6 +401,40 @@ class SignatureTest : AbstractCoreTest() {
}
@Test
+ fun `plain typealias of plain class with annotation`() {
+
+ val writerPlugin = TestOutputWriterPlugin()
+
+ testInline(
+ """
+ |/src/main/kotlin/common/Test.kt
+ |package example
+ |
+ |@MustBeDocumented
+ |@Target(AnnotationTarget.TYPEALIAS)
+ |annotation class SomeAnnotation
+ |
+ |@SomeAnnotation
+ |typealias PlainTypealias = Int
+ |
+ """.trimMargin(),
+ configuration,
+ pluginOverrides = listOf(writerPlugin)
+ ) {
+ renderingStage = { _, _ ->
+ writerPlugin.writer.renderedContent("root/example/index.html").signature().first().match(
+ Div(
+ Div(
+ "@", A("SomeAnnotation"), "()"
+ )
+ ),
+ "typealias ", A("PlainTypealias"), " = ", A("Int"), Span()
+ )
+ }
+ }
+ }
+
+ @Test
fun `plain typealias of generic class`() {
val writerPlugin = TestOutputWriterPlugin()