From 26415d91fcf32f0c70af4f9cea9500bca8187b0e Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Thu, 17 Sep 2020 16:47:07 +0200 Subject: Add processing of annotations to typealiases --- .../src/main/kotlin/signatures/KotlinSignatureProvider.kt | 5 +++-- .../documentables/DeprecatedDocumentableFilterTransformer.kt | 12 +++++++++++- .../descriptors/DefaultDescriptorToDocumentableTranslator.kt | 7 +++++-- 3 files changed, 19 insertions(+), 5 deletions(-) (limited to 'plugins/base/src/main') 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) = + typeAliases.filter { it.isAllowedInPackage() }.let { + Pair(typeAliases.size != it.size, it) + } + private fun filterClasslikes( classlikeList: List ): Pair> { 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( + 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() + ) ) } -- cgit