aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/signatures
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src/main/kotlin/signatures')
-rw-r--r--plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt3
-rw-r--r--plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt39
-rw-r--r--plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt15
3 files changed, 39 insertions, 18 deletions
diff --git a/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt b/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt
index dc5a9543..7ed7ff3f 100644
--- a/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt
+++ b/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt
@@ -20,6 +20,9 @@ interface JvmSignatureUtils {
fun Collection<ExtraModifiers>.toSignatureString(): String =
joinToString("") { it.name.toLowerCase() + " " }
+ @Suppress("UNCHECKED_CAST")
+ fun Documentable.annotations() = (this as? WithExtraProperties<Documentable>)?.annotations() ?: emptyMap()
+
fun <T : AnnotationTarget> WithExtraProperties<T>.annotations(): SourceSetDependent<List<Annotations.Annotation>> =
extra[Annotations]?.directAnnotations ?: emptyMap()
diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
index 24ed0765..2692928b 100644
--- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
+++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
@@ -72,12 +72,12 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
contentBuilder.contentFor(
e,
ContentKind.Symbol,
- setOf(TextStyle.Monospace) + e.stylesIfDeprecated(it),
+ setOf(TextStyle.Monospace),
sourceSets = setOf(it)
) {
group(styles = setOf(TextStyle.Block)) {
annotationsBlock(e)
- link(e.name, e.dri, styles = emptySet())
+ link(e.name, e.dri, styles = mainStyles + e.stylesIfDeprecated(it))
}
}
}
@@ -91,12 +91,12 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
return contentBuilder.contentFor(
c,
ContentKind.Symbol,
- setOf(TextStyle.Monospace) + deprecationStyles,
+ setOf(TextStyle.Monospace),
sourceSets = setOf(sourceSet)
) {
keyword("actual ")
keyword("typealias ")
- link(c.name.orEmpty(), c.dri)
+ link(c.name.orEmpty(), c.dri, styles = mainStyles + deprecationStyles)
operator(" = ")
signatureForProjection(aliasedType)
}
@@ -142,7 +142,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
return contentBuilder.contentFor(
c,
ContentKind.Symbol,
- setOf(TextStyle.Monospace) + deprecationStyles,
+ setOf(TextStyle.Monospace),
sourceSets = setOf(sourceSet)
) {
annotationsBlock(c)
@@ -183,7 +183,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
keyword("annotation class ")
}
}
- link(c.name!!, c.dri)
+ link(c.name!!, c.dri, styles = mainStyles + deprecationStyles)
if (c is WithGenerics) {
list(c.generics, prefix = "<", suffix = ">",
separatorStyles = mainStyles + TokenStyle.Punctuation,
@@ -251,7 +251,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
contentBuilder.contentFor(
p,
ContentKind.Symbol,
- setOf(TextStyle.Monospace) + p.stylesIfDeprecated(sourceSet),
+ setOf(TextStyle.Monospace),
sourceSets = setOf(sourceSet)
) {
annotationsBlock(p)
@@ -272,7 +272,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
signatureForProjection(it.type)
punctuation(".")
}
- link(p.name, p.dri)
+ link(p.name, p.dri, styles = mainStyles + p.stylesIfDeprecated(sourceSet))
operator(": ")
signatureForProjection(p.type)
defaultValueAssign(p, sourceSet)
@@ -298,7 +298,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
contentBuilder.contentFor(
f,
ContentKind.Symbol,
- setOf(TextStyle.Monospace) + f.stylesIfDeprecated(sourceSet),
+ setOf(TextStyle.Monospace),
sourceSets = setOf(sourceSet)
) {
annotationsBlock(f)
@@ -320,7 +320,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
signatureForProjection(it.type)
punctuation(".")
}
- link(f.name, f.dri, styles = mainStyles + TokenStyle.Function)
+ link(f.name, f.dri, styles = mainStyles + TokenStyle.Function + f.stylesIfDeprecated(sourceSet))
// for a function, opening and closing parentheses must be present
// anyway, even if it has no parameters, resulting in `fun test(): R`
@@ -357,14 +357,16 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
+contentBuilder.contentFor(
t,
ContentKind.Symbol,
- setOf(TextStyle.Monospace) + t.stylesIfDeprecated(it),
+ setOf(TextStyle.Monospace),
sourceSets = platforms.toSet()
) {
annotationsBlock(t)
t.visibility[it]?.takeIf { it !in ignoredVisibilities }?.name?.let { keyword("$it ") }
processExtraModifiers(t)
keyword("typealias ")
- signatureForProjection(t.type)
+ group(styles = mainStyles + t.stylesIfDeprecated(it)) {
+ signatureForProjection(t.type)
+ }
operator(" = ")
signatureForTypealiasTarget(t, type)
}
@@ -374,10 +376,15 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
private fun signature(t: DTypeParameter) =
t.sourceSets.map {
- contentBuilder.contentFor(t, styles = t.stylesIfDeprecated(it), sourceSets = setOf(it)) {
- signatureForProjection(t.variantTypeParameter.withDri(t.dri.withTargetToDeclaration()))
- list(t.nontrivialBounds, prefix = " : ",
- surroundingCharactersStyle = mainStyles + TokenStyle.Operator) { bound ->
+ contentBuilder.contentFor(t, sourceSets = setOf(it)) {
+ group(styles = mainStyles + t.stylesIfDeprecated(it)) {
+ signatureForProjection(t.variantTypeParameter.withDri(t.dri.withTargetToDeclaration()))
+ }
+ list(
+ elements = t.nontrivialBounds,
+ prefix = " : ",
+ surroundingCharactersStyle = mainStyles + TokenStyle.Operator
+ ) { bound ->
signatureForProjection(bound)
}
}
diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt
index 381fadf1..ae5275a5 100644
--- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt
+++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt
@@ -1,6 +1,8 @@
package org.jetbrains.dokka.base.signatures
import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder
+import org.jetbrains.dokka.base.transformers.pages.annotations.SinceKotlinTransformer
+import org.jetbrains.dokka.pages.ContentKind
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.links.DriOfAny
import org.jetbrains.dokka.links.DriOfUnit
@@ -10,12 +12,21 @@ import org.jetbrains.dokka.model.properties.WithExtraProperties
object KotlinSignatureUtils : JvmSignatureUtils {
+ private const val classExtension = "::class"
private val strategy = OnlyOnce
private val listBrackets = Pair('[', ']')
- private val classExtension = "::class"
private val ignoredAnnotations = setOf(
+ /**
+ * Rendered separately, see [SinceKotlinTransformer]
+ */
Annotations.Annotation(DRI("kotlin", "SinceKotlin"), emptyMap()),
- Annotations.Annotation(DRI("kotlin", "Deprecated"), emptyMap())
+
+ /**
+ * Rendered separately as its own block, see usage of [ContentKind.Deprecation]
+ */
+ Annotations.Annotation(DRI("kotlin", "Deprecated"), emptyMap()),
+ Annotations.Annotation(DRI("kotlin", "DeprecatedSinceKotlin"), emptyMap()),
+ Annotations.Annotation(DRI("java.lang", "Deprecated"), emptyMap()), // could be used as well for interop
)