diff options
7 files changed, 27 insertions, 29 deletions
diff --git a/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt b/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt index 40f7dfda..8dbe7b12 100644 --- a/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt +++ b/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt @@ -130,7 +130,7 @@ interface JvmSignatureUtils { } } - fun <T : Documentable> WithExtraProperties<T>.stylesForDeprecated(sourceSetData: SourceSetData): Set<TextStyle> = + fun <T : Documentable> WithExtraProperties<T>.stylesIfDeprecated(sourceSetData: SourceSetData): Set<TextStyle> = if (extra[Annotations]?.content?.get(sourceSetData)?.any { it.dri == DRI("kotlin", "Deprecated") || it.dri == DRI("java.lang", "Deprecated") diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt index eee44644..3e92b902 100644 --- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt +++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt @@ -7,7 +7,6 @@ import org.jetbrains.dokka.links.* import org.jetbrains.dokka.model.* import org.jetbrains.dokka.model.Nullable import org.jetbrains.dokka.model.TypeConstructor -import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.model.properties.WithExtraProperties import org.jetbrains.dokka.pages.ContentKind import org.jetbrains.dokka.pages.ContentNode @@ -60,7 +59,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog contentBuilder.contentFor( e, ContentKind.Symbol, - setOf(TextStyle.Monospace, TextStyle.Block) + e.stylesForDeprecated(it), + setOf(TextStyle.Monospace, TextStyle.Block) + e.stylesIfDeprecated(it), sourceSets = setOf(it) ) { group(styles = setOf(TextStyle.Block)) { @@ -78,7 +77,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog contentBuilder.contentFor( c, ContentKind.Symbol, - setOf(TextStyle.Monospace) + ((c as? WithExtraProperties<out Documentable>)?.stylesForDeprecated(sourceSet) + setOf(TextStyle.Monospace) + ((c as? WithExtraProperties<out Documentable>)?.stylesIfDeprecated(sourceSet) ?: emptySet()), sourceSets = setOf(sourceSet) ) { @@ -102,7 +101,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog contentBuilder.contentFor( c, ContentKind.Symbol, - setOf(TextStyle.Monospace) + ((c as? WithExtraProperties<out Documentable>)?.stylesForDeprecated(sourceSet) + setOf(TextStyle.Monospace) + ((c as? WithExtraProperties<out Documentable>)?.stylesIfDeprecated(sourceSet) ?: emptySet()), sourceSets = setOf(sourceSet) ) { @@ -187,7 +186,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog private fun propertySignature(p: DProperty) = p.sourceSets.map { - contentBuilder.contentFor(p, ContentKind.Symbol, setOf(TextStyle.Monospace) + p.stylesForDeprecated(it), sourceSets = setOf(it)) { + contentBuilder.contentFor(p, ContentKind.Symbol, setOf(TextStyle.Monospace) + p.stylesIfDeprecated(it), sourceSets = setOf(it)) { annotationsBlock(p) text(p.visibility[it].takeIf { it !in ignoredVisibilities }?.name?.let { "$it " } ?: "") text( @@ -212,7 +211,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog private fun functionSignature(f: DFunction) = f.sourceSets.map { - contentBuilder.contentFor(f, ContentKind.Symbol, setOf(TextStyle.Monospace) + f.stylesForDeprecated(it), sourceSets = setOf(it)) { + contentBuilder.contentFor(f, ContentKind.Symbol, setOf(TextStyle.Monospace) + f.stylesIfDeprecated(it), sourceSets = setOf(it)) { annotationsBlock(f) text(f.visibility[it]?.takeIf { it !in ignoredVisibilities }?.name?.let { "$it " } ?: "") text(f.modifier[it]?.takeIf { it !in ignoredModifiers }?.let { @@ -254,7 +253,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog private fun signature(t: DTypeAlias) = t.sourceSets.map { - contentBuilder.contentFor(t, styles = t.stylesForDeprecated(it), sourceSets = setOf(it)) { + contentBuilder.contentFor(t, styles = t.stylesIfDeprecated(it), sourceSets = setOf(it)) { t.underlyingType.entries.groupBy({ it.value }, { it.key }).map { (type, platforms) -> +contentBuilder.contentFor( t, @@ -275,7 +274,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog private fun signature(t: DTypeParameter) = t.sourceSets.map { - contentBuilder.contentFor(t, styles = t.stylesForDeprecated(it), sourceSets = setOf(it)) { + contentBuilder.contentFor(t, styles = t.stylesIfDeprecated(it), sourceSets = setOf(it)) { link(t.name, t.dri.withTargetToDeclaration()) list(t.bounds, prefix = " : ") { signatureForProjection(it) diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt index 5e35c240..4fcb9761 100644 --- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt +++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt @@ -10,7 +10,7 @@ object KotlinSignatureUtils : JvmSignatureUtils { private val strategy = OnlyOnce private val listBrackets = Pair('[', ']') private val classExtension = "::class" - val ignoredAnnotations = setOf( + private val ignoredAnnotations = setOf( Annotations.Annotation(DRI("kotlin", "SinceKotlin"), emptyMap()), Annotations.Annotation(DRI("kotlin", "Deprecated"), emptyMap()) ) diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index ad872e2a..49d8ae0f 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -696,16 +696,15 @@ private class DokkaDescriptorVisitor( else -> StringValue(toString()) } - private fun AnnotationDescriptor.toAnnotation(): Annotations.Annotation? = - DRI.from(annotationClass as DeclarationDescriptor).let { - Annotations.Annotation( - it, - allValueArguments.map { it.key.asString() to it.value.toValue() }.filter { - it.second != null - }.toMap() as Map<String, AnnotationParameterValue>, - annotationClass!!.annotations.hasAnnotation(FqName("kotlin.annotation.MustBeDocumented")) - ) - } + private fun AnnotationDescriptor.toAnnotation(): Annotations.Annotation { + return Annotations.Annotation( + DRI.from(annotationClass as DeclarationDescriptor), + allValueArguments.map { it.key.asString() to it.value.toValue() }.filter { + it.second != null + }.toMap() as Map<String, AnnotationParameterValue>, + annotationClass!!.annotations.hasAnnotation(FqName("kotlin.annotation.MustBeDocumented")) + ) + } private fun PropertyDescriptor.getAnnotationsWithBackingField(): List<Annotations.Annotation> = getAnnotations() + (backingField?.getAnnotations() ?: emptyList()) diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt index f3102b2d..a5117b09 100644 --- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt @@ -429,12 +429,12 @@ object DefaultPsiToDocumentableTranslator : SourceToDocumentableTranslator { else -> StringValue(text ?: "") } - private fun PsiAnnotation.toAnnotation() = psiReference?.let { + private fun PsiAnnotation.toAnnotation() = psiReference?.let { psiElement -> Annotations.Annotation( - DRI.from(it), + DRI.from(psiElement), attributes.filter { it !is KtLightAbstractAnnotation }.mapNotNull { it.attributeName to it.toValue() } .toMap(), - (it as PsiClass).annotations.any { + (psiElement as PsiClass).annotations.any { hasQualifiedName("java.lang.annotation.Documented") } ) diff --git a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt index ed273e5c..c6fcb9b0 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt @@ -39,7 +39,7 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge contentBuilder.contentFor( e, ContentKind.Symbol, - setOf(TextStyle.Monospace) + e.stylesForDeprecated(it), + setOf(TextStyle.Monospace) + e.stylesIfDeprecated(it), sourceSets = setOf(it) ) { link(e.name, e.dri) @@ -51,7 +51,7 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge contentBuilder.contentFor( c, ContentKind.Symbol, - setOf(TextStyle.Monospace) + ((c as? WithExtraProperties<out Documentable>)?.stylesForDeprecated(it) + setOf(TextStyle.Monospace) + ((c as? WithExtraProperties<out Documentable>)?.stylesIfDeprecated(it) ?: emptySet()), sourceSets = setOf(it) ) { @@ -90,7 +90,7 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge contentBuilder.contentFor( p, ContentKind.Symbol, - setOf(TextStyle.Monospace, TextStyle.Block) + p.stylesForDeprecated(it), + setOf(TextStyle.Monospace, TextStyle.Block) + p.stylesIfDeprecated(it), sourceSets = setOf(it) ) { annotationsBlock(p) @@ -108,7 +108,7 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge contentBuilder.contentFor( f, ContentKind.Symbol, - setOf(TextStyle.Monospace, TextStyle.Block) + f.stylesForDeprecated(it), + setOf(TextStyle.Monospace, TextStyle.Block) + f.stylesIfDeprecated(it), sourceSets = setOf(it) ) { annotationsBlock(f) @@ -134,7 +134,7 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge private fun signature(t: DTypeParameter) = t.sourceSets.map { - contentBuilder.contentFor(t, styles = t.stylesForDeprecated(it), sourceSets = setOf(it)) { + contentBuilder.contentFor(t, styles = t.stylesIfDeprecated(it), sourceSets = setOf(it)) { text(t.name.substringAfterLast(".")) list(t.bounds, prefix = " extends ") { signatureForProjection(it) diff --git a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureUtils.kt b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureUtils.kt index b4245834..ecb97617 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureUtils.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureUtils.kt @@ -9,7 +9,7 @@ import org.jetbrains.dokka.model.properties.WithExtraProperties object JavaSignatureUtils : JvmSignatureUtils { - val ignoredAnnotations = setOf( + private val ignoredAnnotations = setOf( Annotations.Annotation(DRI("kotlin.jvm", "Transient"), emptyMap()), Annotations.Annotation(DRI("kotlin.jvm", "Volatile"), emptyMap()), Annotations.Annotation(DRI("kotlin.jvm", "Transitive"), emptyMap()), |