diff options
| author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2022-08-18 19:33:53 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-18 19:33:53 +0200 |
| commit | 50a3323322265ff3b5dab1d861a25bbb1167812a (patch) | |
| tree | 0966cfab6d9155724a65439a5c0d1476d66b0a7a /plugins/base/src/main/kotlin/transformers/documentables | |
| parent | df8d9879b818799c83ff731b3a78e7d2b96fd8e5 (diff) | |
| download | dokka-50a3323322265ff3b5dab1d861a25bbb1167812a.tar.gz dokka-50a3323322265ff3b5dab1d861a25bbb1167812a.tar.bz2 dokka-50a3323322265ff3b5dab1d861a25bbb1167812a.zip | |
Add deprecation details block (#2622)
Diffstat (limited to 'plugins/base/src/main/kotlin/transformers/documentables')
| -rw-r--r-- | plugins/base/src/main/kotlin/transformers/documentables/utils.kt | 22 |
1 files changed, 16 insertions, 6 deletions
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> T.isDeprecated() where T : WithExtraProperties<out Documentable> = - deprecatedAnnotation != null +val <T : WithExtraProperties<out Documentable>> T.isException: Boolean + get() = extra[ExceptionInSupertypes] != null + val <T> T.deprecatedAnnotation where T : WithExtraProperties<out Documentable> 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 : WithExtraProperties<out Documentable>> 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> T.isDeprecated() where T : WithExtraProperties<out Documentable> = 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") |
