From 50a3323322265ff3b5dab1d861a25bbb1167812a Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Thu, 18 Aug 2022 19:33:53 +0200 Subject: Add deprecation details block (#2622) --- .../kotlin/transformers/documentables/utils.kt | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'plugins/base/src/main/kotlin/transformers/documentables') diff --git a/plugins/base/src/main/kotlin/transformers/documentables/utils.kt b/plugins/base/src/main/kotlin/transformers/documentables/utils.kt index 2a5fbc11..079cebea 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/utils.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/utils.kt @@ -5,16 +5,26 @@ import org.jetbrains.dokka.model.Documentable import org.jetbrains.dokka.model.ExceptionInSupertypes import org.jetbrains.dokka.model.properties.WithExtraProperties -fun T.isDeprecated() where T : WithExtraProperties = - deprecatedAnnotation != null +val > T.isException: Boolean + get() = extra[ExceptionInSupertypes] != null + val T.deprecatedAnnotation where T : WithExtraProperties get() = extra[Annotations]?.let { annotations -> annotations.directAnnotations.values.flatten().firstOrNull { - it.dri.toString() == "kotlin/Deprecated///PointingToDeclaration/" || - it.dri.toString() == "java.lang/Deprecated///PointingToDeclaration/" + it.isDeprecated() } } -val > T.isException: Boolean - get() = extra[ExceptionInSupertypes] != null \ No newline at end of file +/** + * @return true if [T] has [kotlin.Deprecated] or [java.lang.Deprecated] + * annotation for **any** source set + */ +fun T.isDeprecated() where T : WithExtraProperties = deprecatedAnnotation != null + +/** + * @return true for [kotlin.Deprecated] and [java.lang.Deprecated] + */ +fun Annotations.Annotation.isDeprecated() = + (this.dri.packageName == "kotlin" && this.dri.classNames == "Deprecated") || + (this.dri.packageName == "java.lang" && this.dri.classNames == "Deprecated") -- cgit