diff options
author | Marcin Aman <marcin.aman@gmail.com> | 2021-02-05 14:55:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-05 14:55:45 +0100 |
commit | 70000c87a37caa2a6b518a555f53c98514434403 (patch) | |
tree | 3a0e7a2b797b6edfffc0396bb5f9d35708120e9d /plugins/base/src/main/kotlin/signatures | |
parent | b44e41ec8e3e26c73affaaa98bbd170fde352d96 (diff) | |
download | dokka-70000c87a37caa2a6b518a555f53c98514434403.tar.gz dokka-70000c87a37caa2a6b518a555f53c98514434403.tar.bz2 dokka-70000c87a37caa2a6b518a555f53c98514434403.zip |
Annotations for parameters (#1710)
* Annotations for parameters
* Annotations for parameters
Diffstat (limited to 'plugins/base/src/main/kotlin/signatures')
3 files changed, 32 insertions, 16 deletions
diff --git a/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt b/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt index 3851b39c..a5aa6879 100644 --- a/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt +++ b/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt @@ -6,25 +6,25 @@ import org.jetbrains.dokka.model.* import org.jetbrains.dokka.model.properties.WithExtraProperties import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet -import org.jetbrains.dokka.base.signatures.KotlinSignatureUtils.driOrNull import org.jetbrains.dokka.base.signatures.KotlinSignatureUtils.drisOfAllNestedBounds +import org.jetbrains.dokka.model.AnnotationTarget interface JvmSignatureUtils { - fun PageContentBuilder.DocumentableContentBuilder.annotationsBlock(d: Documentable) + fun PageContentBuilder.DocumentableContentBuilder.annotationsBlock(d: AnnotationTarget) - fun PageContentBuilder.DocumentableContentBuilder.annotationsInline(d: Documentable) + fun PageContentBuilder.DocumentableContentBuilder.annotationsInline(d: AnnotationTarget) fun <T : Documentable> WithExtraProperties<T>.modifiers(): SourceSetDependent<Set<ExtraModifiers>> fun Collection<ExtraModifiers>.toSignatureString(): String = joinToString("") { it.name.toLowerCase() + " " } - fun <T : Documentable> WithExtraProperties<T>.annotations(): SourceSetDependent<List<Annotations.Annotation>> = + fun <T : AnnotationTarget> WithExtraProperties<T>.annotations(): SourceSetDependent<List<Annotations.Annotation>> = extra[Annotations]?.directAnnotations ?: emptyMap() private fun PageContentBuilder.DocumentableContentBuilder.annotations( - d: Documentable, + d: AnnotationTarget, ignored: Set<Annotations.Annotation>, styles: Set<Style>, operation: PageContentBuilder.DocumentableContentBuilder.(Annotations.Annotation) -> Unit @@ -40,6 +40,10 @@ interface JvmSignatureUtils { is DEnumEntry -> d.annotations() is DTypeAlias -> d.annotations() is DParameter -> d.annotations() + is TypeParameter -> d.annotations() + is GenericTypeConstructor -> d.annotations() + is FunctionalTypeConstructor -> d.annotations() + is JavaObject -> d.annotations() else -> null }?.let { it.entries.forEach { @@ -104,7 +108,7 @@ interface JvmSignatureUtils { } fun PageContentBuilder.DocumentableContentBuilder.annotationsBlockWithIgnored( - d: Documentable, + d: AnnotationTarget, ignored: Set<Annotations.Annotation>, renderAtStrategy: AtStrategy, listBrackets: Pair<Char, Char>, @@ -118,7 +122,7 @@ interface JvmSignatureUtils { } fun PageContentBuilder.DocumentableContentBuilder.annotationsInlineWithIgnored( - d: Documentable, + d: AnnotationTarget, ignored: Set<Annotations.Annotation>, renderAtStrategy: AtStrategy, listBrackets: Pair<Char, Char>, diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt index 7f29e032..4eac9d3f 100644 --- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt +++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt @@ -164,6 +164,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog link(c.name!!, c.dri) if (c is WithGenerics) { list(c.generics, prefix = "<", suffix = ">") { + annotationsInline(it) +buildSignature(it) } } @@ -219,6 +220,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog text(p.modifiers()[it]?.toSignatureString() ?: "") p.setter?.let { text("var ") } ?: text("val ") list(p.generics, prefix = "<", suffix = "> ") { + annotationsInline(it) +buildSignature(it) } p.receiver?.also { @@ -252,6 +254,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog text("fun ") val usedGenerics = if (f.isConstructor) f.generics.filter { f uses it } else f.generics list(usedGenerics, prefix = "<", suffix = "> ") { + annotationsInline(it) +buildSignature(it) } f.receiver?.also { @@ -328,19 +331,23 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog private fun PageContentBuilder.DocumentableContentBuilder.signatureForProjection( p: Projection, showFullyQualifiedName: Boolean = false - ): Unit = - when (p) { - is TypeParameter -> link(p.name, p.dri) - - is FunctionalTypeConstructor -> + ): Unit { + return when (p) { + is TypeParameter -> { + annotationsInline(p) + link(p.name, p.dri) + } + is FunctionalTypeConstructor -> { + annotationsInline(p) +funType(mainDRI.single(), mainSourcesetData, p) - + } is GenericTypeConstructor -> group(styles = emptySet()) { val linkText = if (showFullyQualifiedName && p.dri.packageName != null) { "${p.dri.packageName}.${p.dri.classNames.orEmpty()}" } else p.dri.classNames.orEmpty() if (p.presentableName != null) text(p.presentableName + ": ") + annotationsInline(p) link(linkText, p.dri) list(p.projections, prefix = "<", suffix = ">") { signatureForProjection(it, showFullyQualifiedName) @@ -360,12 +367,16 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog } is TypeAliased -> signatureForProjection(p.typeAlias) - is JavaObject -> link("Any", DriOfAny) + is JavaObject -> { + annotationsInline(p) + link("Any", DriOfAny) + } is Void -> link("Unit", DriOfUnit) is PrimitiveJavaType -> signatureForProjection(p.translateToKotlin(), showFullyQualifiedName) is Dynamic -> text("dynamic") is UnresolvedBound -> text(p.name) } + } private fun funType(dri: DRI, sourceSets: Set<DokkaSourceSet>, type: FunctionalTypeConstructor) = contentBuilder.contentFor(dri, sourceSets, ContentKind.Main) { diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt index 2266b691..bb350b34 100644 --- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt +++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt @@ -5,6 +5,7 @@ import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.links.DriOfAny import org.jetbrains.dokka.links.DriOfUnit import org.jetbrains.dokka.model.* +import org.jetbrains.dokka.model.AnnotationTarget import org.jetbrains.dokka.model.properties.WithExtraProperties object KotlinSignatureUtils : JvmSignatureUtils { @@ -18,10 +19,10 @@ object KotlinSignatureUtils : JvmSignatureUtils { ) - override fun PageContentBuilder.DocumentableContentBuilder.annotationsBlock(d: Documentable) = + override fun PageContentBuilder.DocumentableContentBuilder.annotationsBlock(d: AnnotationTarget) = annotationsBlockWithIgnored(d, ignoredAnnotations, strategy, listBrackets, classExtension) - override fun PageContentBuilder.DocumentableContentBuilder.annotationsInline(d: Documentable) = + override fun PageContentBuilder.DocumentableContentBuilder.annotationsInline(d: AnnotationTarget) = annotationsInlineWithIgnored(d, ignoredAnnotations, strategy, listBrackets, classExtension) override fun <T : Documentable> WithExtraProperties<T>.modifiers() = |