aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAndrzej Ratajczak <andrzej.ratajczak98@gmail.com>2020-06-15 13:47:30 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-06-25 14:56:46 +0200
commitfa8b850977788339d1ce62cd0e3e87e681071584 (patch)
tree904971df1033f285d254048bf5d31ea0ef0cd527 /plugins
parent44650369a1f151ddbf890a1d370daea0b7982124 (diff)
downloaddokka-fa8b850977788339d1ce62cd0e3e87e681071584.tar.gz
dokka-fa8b850977788339d1ce62cd0e3e87e681071584.tar.bz2
dokka-fa8b850977788339d1ce62cd0e3e87e681071584.zip
Make signatures groups be unique per sourceSet data
Diffstat (limited to 'plugins')
-rw-r--r--plugins/base/src/main/kotlin/DokkaBase.kt5
-rw-r--r--plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt7
-rw-r--r--plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt235
-rw-r--r--plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt5
-rw-r--r--plugins/base/src/main/kotlin/signatures/SignatureProvider.kt2
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/annotations/DeprecatedStrikethroughTransformer.kt67
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt154
7 files changed, 231 insertions, 244 deletions
diff --git a/plugins/base/src/main/kotlin/DokkaBase.kt b/plugins/base/src/main/kotlin/DokkaBase.kt
index 9a04e729..18402863 100644
--- a/plugins/base/src/main/kotlin/DokkaBase.kt
+++ b/plugins/base/src/main/kotlin/DokkaBase.kt
@@ -14,7 +14,6 @@ import org.jetbrains.dokka.base.transformers.documentables.DefaultDocumentableMe
import org.jetbrains.dokka.base.transformers.documentables.DocumentableVisibilityFilter
import org.jetbrains.dokka.base.transformers.documentables.ModuleAndPackageDocumentationTransformer
import org.jetbrains.dokka.base.transformers.documentables.ReportUndocumentedTransformer
-import org.jetbrains.dokka.base.transformers.pages.annotations.DeprecatedStrikethroughTransformer
import org.jetbrains.dokka.base.transformers.pages.annotations.SinceKotlinTransformer
import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter
import org.jetbrains.dokka.base.transformers.pages.comments.DocTagToContentConverter
@@ -110,10 +109,6 @@ class DokkaBase : DokkaPlugin() {
}
}
- val deprecatedStrikethroughTransformer by extending {
- CoreExtensions.pageTransformer providing ::DeprecatedStrikethroughTransformer
- }
-
val htmlRenderer by extending {
CoreExtensions.renderer providing ::HtmlRenderer applyIf { format == "html" }
}
diff --git a/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt b/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt
index a551efdc..40f7dfda 100644
--- a/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt
+++ b/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt
@@ -1,6 +1,7 @@
package org.jetbrains.dokka.base.signatures
import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder
+import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.*
import org.jetbrains.dokka.model.properties.WithExtraProperties
import org.jetbrains.dokka.pages.*
@@ -128,6 +129,12 @@ interface JvmSignatureUtils {
text(Typography.nbsp.toString())
}
}
+
+ fun <T : Documentable> WithExtraProperties<T>.stylesForDeprecated(sourceSetData: SourceSetData): Set<TextStyle> =
+ if (extra[Annotations]?.content?.get(sourceSetData)?.any {
+ it.dri == DRI("kotlin", "Deprecated")
+ || it.dri == DRI("java.lang", "Deprecated")
+ } == true) setOf(TextStyle.Strikethrough) else emptySet()
}
sealed class AtStrategy
diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
index faca95ee..66596e2d 100644
--- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
+++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
@@ -7,6 +7,7 @@ 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
@@ -28,7 +29,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
ExtraModifiers.KotlinOnlyModifiers.External to setOf(Platform.js)
)
- override fun signature(documentable: Documentable): ContentNode = when (documentable) {
+ override fun signature(documentable: Documentable): List<ContentNode> = when (documentable) {
is DFunction -> functionSignature(documentable)
is DProperty -> propertySignature(documentable)
is DClasslike -> classlikeSignature(documentable)
@@ -54,54 +55,65 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
}
}
- private fun signature(e: DEnumEntry) =
- contentBuilder.contentFor(
- e,
- ContentKind.Symbol,
- setOf(TextStyle.Monospace),
- sourceSets = e.sourceSets.toSet()
- ) {
- group(styles = setOf(TextStyle.Block)) {
- annotationsBlock(e)
- link(e.name, e.dri, styles = emptySet())
- e.extra[ConstructorValues]?.let { constructorValues ->
- sourceSetDependentText(constructorValues.values, constructorValues.values.keys) {
- it.joinToString(prefix = "(", postfix = ")")
+ private fun signature(e: DEnumEntry): List<ContentNode> =
+ e.sourceSets.map {
+ contentBuilder.contentFor(
+ e,
+ ContentKind.Symbol,
+ setOf(TextStyle.Monospace) + e.stylesForDeprecated(it),
+ sourceSets = setOf(it)
+ ) {
+ group(styles = setOf(TextStyle.Block)) {
+ annotationsBlock(e)
+ link(e.name, e.dri, styles = emptySet())
+ e.extra[ConstructorValues]?.let { constructorValues ->
+ sourceSetDependentText(constructorValues.values, constructorValues.values.keys) {
+ it.joinToString(prefix = "(", postfix = ")")
+ }
}
}
}
}
- private fun actualTypealiasedSignature(dri: DRI, name: String, aliasedTypes: SourceSetDependent<Bound>) =
- aliasedTypes.entries.groupBy({ it.value }, { it.key }).map { (bound, platforms) ->
- contentBuilder.contentFor(dri, platforms.toSet(), ContentKind.Symbol, setOf(TextStyle.Monospace)) {
- text("actual typealias ")
- link(name, dri)
- text(" = ")
- signatureForProjection(bound)
- }
+ private fun actualTypealiasedSignature(c: DClasslike, sourceSet: SourceSetData, aliasedType: Bound) =
+ contentBuilder.contentFor(
+ c,
+ ContentKind.Symbol,
+ setOf(TextStyle.Monospace) + ((c as? WithExtraProperties<out Documentable>)?.stylesForDeprecated(sourceSet)
+ ?: emptySet()),
+ sourceSets = setOf(sourceSet)
+ ) {
+ text("actual typealias ")
+ link(c.name.orEmpty(), c.dri)
+ text(" = ")
+ signatureForProjection(aliasedType)
}
@Suppress("UNCHECKED_CAST")
- private fun <T : DClasslike> classlikeSignature(c: T) =
- (c as? WithExtraProperties<out DClasslike>)?.let {
- c.extra[ActualTypealias]?.let {
- contentBuilder.contentFor(c) {
- +regularSignature(c, sourceSets = c.sourceSets.toSet() - it.underlyingType.keys)
- +actualTypealiasedSignature(c.dri, c.name.orEmpty(), it.underlyingType)
- }
- } ?: regularSignature(c)
- } ?: regularSignature(c)
+ private fun <T : DClasslike> classlikeSignature(c: T): List<ContentNode> =
+ c.sourceSets.map { sourceSetData ->
+ (c as? WithExtraProperties<out DClasslike>)?.extra?.get(ActualTypealias)?.underlyingType?.get(sourceSetData)
+ ?.let {
+ actualTypealiasedSignature(c, sourceSetData, it)
+ } ?: regularSignature(c, sourceSetData)
+ }
- private fun regularSignature(c: DClasslike, sourceSets: Set<SourceSetData> = c.sourceSets.toSet()) =
- contentBuilder.contentFor(c, ContentKind.Symbol, setOf(TextStyle.Monospace), sourceSets = sourceSets) {
+
+ private fun regularSignature(c: DClasslike, sourceSet: SourceSetData) =
+ contentBuilder.contentFor(
+ c,
+ ContentKind.Symbol,
+ setOf(TextStyle.Monospace) + ((c as? WithExtraProperties<out Documentable>)?.stylesForDeprecated(sourceSet)
+ ?: emptySet()),
+ sourceSets = setOf(sourceSet)
+ ) {
annotationsBlock(c)
sourceSetDependentText(
c.visibility,
- sourceSets
+ setOf(sourceSet)
) { it.takeIf { it !in ignoredVisibilities }?.name?.let { "$it " } ?: "" }
if (c is DClass) {
- sourceSetDependentText(c.modifier, sourceSets) {
+ sourceSetDependentText(c.modifier, setOf(sourceSet)) {
if (it !in ignoredModifiers)
if (c.extra[AdditionalModifiers]?.content?.contains(ExtraModifiers.KotlinOnlyModifiers.Data) == true) ""
else (if (it is JavaModifier.Empty) KotlinModifier.Open else it).let { it.name + " " }
@@ -111,7 +123,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
}
if (c is DInterface) {
c.extra[AdditionalModifiers]?.content?.let { additionalModifiers ->
- sourceSetDependentText(additionalModifiers, sourceSets) { extraModifiers ->
+ sourceSetDependentText(additionalModifiers, setOf(sourceSet)) { extraModifiers ->
if (ExtraModifiers.KotlinOnlyModifiers.Fun in extraModifiers) "fun "
else ""
}
@@ -166,7 +178,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
}
}
if (c is WithSupertypes) {
- c.supertypes.filter { it.key in sourceSets }.map { (s, dris) ->
+ c.supertypes.filter { it.key == sourceSet }.map { (s, dris) ->
list(dris, prefix = " : ", sourceSets = setOf(s)) {
link(it.sureClassNames, it, sourceSets = setOf(s))
}
@@ -174,60 +186,64 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
}
}
- private fun propertySignature(p: DProperty, sourceSets: Set<SourceSetData> = p.sourceSets.toSet()) =
- contentBuilder.contentFor(p, ContentKind.Symbol, setOf(TextStyle.Monospace), sourceSets = sourceSets) {
- annotationsBlock(p)
- sourceSetDependentText(p.visibility) { it.takeIf { it !in ignoredVisibilities }?.name?.let { "$it " } ?: "" }
- sourceSetDependentText(p.modifier) {
- it.takeIf { it !in ignoredModifiers }?.let {
- if (it is JavaModifier.Empty) KotlinModifier.Open else it
- }?.name?.let { "$it " } ?: ""
- }
- processExtraModifiers(p)
- p.setter?.let { text("var ") } ?: text("val ")
- list(p.generics, prefix = "<", suffix = "> ") {
- +buildSignature(it)
- }
- p.receiver?.also {
- signatureForProjection(it.type)
- text(".")
+ private fun propertySignature(p: DProperty) =
+ p.sourceSets.map {
+ contentBuilder.contentFor(p, ContentKind.Symbol, setOf(TextStyle.Monospace) + p.stylesForDeprecated(it), sourceSets = setOf(it)) {
+ annotationsBlock(p)
+ sourceSetDependentText(p.visibility) { it.takeIf { it !in ignoredVisibilities }?.name?.let { "$it " } ?: "" }
+ sourceSetDependentText(p.modifier) {
+ it.takeIf { it !in ignoredModifiers }?.let {
+ if (it is JavaModifier.Empty) KotlinModifier.Open else it
+ }?.name?.let { "$it " } ?: ""
+ }
+ processExtraModifiers(p)
+ p.setter?.let { text("var ") } ?: text("val ")
+ list(p.generics, prefix = "<", suffix = "> ") {
+ +buildSignature(it)
+ }
+ p.receiver?.also {
+ signatureForProjection(it.type)
+ text(".")
+ }
+ link(p.name, p.dri)
+ text(": ")
+ signatureForProjection(p.type)
}
- link(p.name, p.dri)
- text(": ")
- signatureForProjection(p.type)
}
- private fun functionSignature(f: DFunction, sourceSets: Set<SourceSetData> = f.sourceSets.toSet()) =
- contentBuilder.contentFor(f, ContentKind.Symbol, setOf(TextStyle.Monospace), sourceSets = sourceSets) {
- annotationsBlock(f)
- sourceSetDependentText(f.visibility) { it.takeIf { it !in ignoredVisibilities }?.name?.let { "$it " } ?: "" }
- sourceSetDependentText(f.modifier) {
- it.takeIf { it !in ignoredModifiers }?.let {
- if (it is JavaModifier.Empty) KotlinModifier.Open else it
- }?.name?.let { "$it " } ?: ""
- }
- processExtraModifiers(f)
- text("fun ")
- list(f.generics, prefix = "<", suffix = "> ") {
- +buildSignature(it)
- }
- f.receiver?.also {
- signatureForProjection(it.type)
- text(".")
- }
- link(f.name, f.dri)
- text("(")
- list(f.parameters) {
- annotationsInline(it)
- processExtraModifiers(it)
- text(it.name!!)
- text(": ")
- signatureForProjection(it.type)
- }
- text(")")
- if (f.documentReturnType()) {
- text(": ")
- signatureForProjection(f.type)
+ private fun functionSignature(f: DFunction) =
+ f.sourceSets.map {
+ contentBuilder.contentFor(f, ContentKind.Symbol, setOf(TextStyle.Monospace) + f.stylesForDeprecated(it), sourceSets = setOf(it)) {
+ annotationsBlock(f)
+ sourceSetDependentText(f.visibility) { it.takeIf { it !in ignoredVisibilities }?.name?.let { "$it " } ?: "" }
+ sourceSetDependentText(f.modifier) {
+ it.takeIf { it !in ignoredModifiers }?.let {
+ if (it is JavaModifier.Empty) KotlinModifier.Open else it
+ }?.name?.let { "$it " } ?: ""
+ }
+ processExtraModifiers(f)
+ text("fun ")
+ list(f.generics, prefix = "<", suffix = "> ") {
+ +buildSignature(it)
+ }
+ f.receiver?.also {
+ signatureForProjection(it.type)
+ text(".")
+ }
+ link(f.name, f.dri)
+ text("(")
+ list(f.parameters) {
+ annotationsInline(it)
+ processExtraModifiers(it)
+ text(it.name!!)
+ text(": ")
+ signatureForProjection(it.type)
+ }
+ text(")")
+ if (f.documentReturnType()) {
+ text(": ")
+ signatureForProjection(f.type)
+ }
}
}
@@ -239,30 +255,35 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
}
private fun signature(t: DTypeAlias) =
- contentBuilder.contentFor(t) {
- t.underlyingType.entries.groupBy({ it.value }, { it.key }).map { (type, platforms) ->
- +contentBuilder.contentFor(
- t,
- ContentKind.Symbol,
- setOf(TextStyle.Monospace),
- sourceSets = platforms.toSet()
- ) {
- sourceSetDependentText(t.visibility) { it.takeIf { it !in ignoredVisibilities }?.name?.let { "$it " } ?: "" }
- processExtraModifiers(t)
- text("typealias ")
- signatureForProjection(t.type)
- text(" = ")
- signatureForProjection(type)
+ t.sourceSets.map {
+ contentBuilder.contentFor(t, styles = t.stylesForDeprecated(it), sourceSets = setOf(it)) {
+ t.underlyingType.entries.groupBy({ it.value }, { it.key }).map { (type, platforms) ->
+ +contentBuilder.contentFor(
+ t,
+ ContentKind.Symbol,
+ setOf(TextStyle.Monospace),
+ sourceSets = platforms.toSet()
+ ) {
+ sourceSetDependentText(t.visibility) { it.takeIf { it !in ignoredVisibilities }?.name?.let { "$it " } ?: "" }
+ processExtraModifiers(t)
+ text("typealias ")
+ signatureForProjection(t.type)
+ text(" = ")
+ signatureForProjection(type)
+ }
}
}
}
- private fun signature(t: DTypeParameter) = contentBuilder.contentFor(t) {
- link(t.name, t.dri.withTargetToDeclaration())
- list(t.bounds, prefix = " : ") {
- signatureForProjection(it)
+ private fun signature(t: DTypeParameter) =
+ t.sourceSets.map {
+ contentBuilder.contentFor(t, styles = t.stylesForDeprecated(it), sourceSets = setOf(it)) {
+ link(t.name, t.dri.withTargetToDeclaration())
+ list(t.bounds, prefix = " : ") {
+ signatureForProjection(it)
+ }
+ }
}
- }
private fun PageContentBuilder.DocumentableContentBuilder.signatureForProjection(p: Projection): Unit =
when (p) {
diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt
index b312c8f0..5e35c240 100644
--- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt
+++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt
@@ -2,10 +2,7 @@ package org.jetbrains.dokka.base.signatures
import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder
import org.jetbrains.dokka.links.DRI
-import org.jetbrains.dokka.model.AdditionalModifiers
-import org.jetbrains.dokka.model.Annotations
-import org.jetbrains.dokka.model.Documentable
-import org.jetbrains.dokka.model.ExtraModifiers
+import org.jetbrains.dokka.model.*
import org.jetbrains.dokka.model.properties.WithExtraProperties
object KotlinSignatureUtils : JvmSignatureUtils {
diff --git a/plugins/base/src/main/kotlin/signatures/SignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/SignatureProvider.kt
index 01b298c9..e1933fb8 100644
--- a/plugins/base/src/main/kotlin/signatures/SignatureProvider.kt
+++ b/plugins/base/src/main/kotlin/signatures/SignatureProvider.kt
@@ -4,5 +4,5 @@ import org.jetbrains.dokka.model.Documentable
import org.jetbrains.dokka.pages.ContentNode
interface SignatureProvider {
- fun signature(documentable: Documentable): ContentNode
+ fun signature(documentable: Documentable): List<ContentNode>
}
diff --git a/plugins/base/src/main/kotlin/transformers/pages/annotations/DeprecatedStrikethroughTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/annotations/DeprecatedStrikethroughTransformer.kt
deleted file mode 100644
index ffee64ed..00000000
--- a/plugins/base/src/main/kotlin/transformers/pages/annotations/DeprecatedStrikethroughTransformer.kt
+++ /dev/null
@@ -1,67 +0,0 @@
-package org.jetbrains.dokka.base.transformers.pages.annotations
-
-import org.jetbrains.dokka.base.renderers.platforms
-import org.jetbrains.dokka.links.DRI
-import org.jetbrains.dokka.model.*
-import org.jetbrains.dokka.model.properties.WithExtraProperties
-import org.jetbrains.dokka.pages.*
-import org.jetbrains.dokka.plugability.DokkaContext
-import org.jetbrains.dokka.transformers.pages.PageTransformer
-import org.jetbrains.kotlin.utils.addToStdlib.ifNotEmpty
-
-class DeprecatedStrikethroughTransformer(val context: DokkaContext) : PageTransformer {
-
- override fun invoke(input: RootPageNode): RootPageNode = input.transformContentPagesTree { contentPage ->
- contentPage.platforms().fold(contentPage) { acc, sourceSetData ->
- listOfNotNull(
- contentPage.documentable?.children?.filter { it.isDeprecated(sourceSetData) }?.map { it.dri },
- contentPage.dri.takeIf { acc.documentable?.isDeprecated(sourceSetData) == true }?.toList()
- ).flatten().ifNotEmpty {
- acc.modified(content = acc.content.addStrikethroughToSignature(sourceSetData, this.toSet()))
- } ?: acc
- }
- }
-
- private fun ContentNode.addStrikethroughToSignature(
- sourceSetData: SourceSetData,
- deprecatedDRIs: Set<DRI>
- ): ContentNode = when (this) {
- is ContentGroup -> if (setOf(sourceSetData) == sourceSets && deprecatedDRIs.containsAll(dci.dri)) {
- copy(style = this.style + setOf(TextStyle.Strikethrough))
- } else {
- copy(children = children.map { it.addStrikethroughToSignature(sourceSetData, deprecatedDRIs) })
- }
- is ContentTable -> copy(children = children.map {
- it.addStrikethroughToSignature(
- sourceSetData,
- deprecatedDRIs
- ) as ContentGroup
- })
- is PlatformHintedContent -> copy(inner = inner.addStrikethroughToSignature(sourceSetData, deprecatedDRIs))
- is ContentDivergentGroup -> copy(children = children.map { it.addStrikethroughToSignature(sourceSetData, deprecatedDRIs) } as List<ContentDivergentInstance>)
- is ContentDivergentInstance -> copy(divergent = divergent.addStrikethroughToSignature(sourceSetData, deprecatedDRIs))
- else -> this
- }
-
- private fun Documentable.isDeprecated(sourceSetData: SourceSetData) = when (this) {
- is DClass -> this.isKotlinOrJavaDeprecated(sourceSetData)
- is DAnnotation -> this.isKotlinOrJavaDeprecated(sourceSetData)
- is DObject -> this.isKotlinOrJavaDeprecated(sourceSetData)
- is DInterface -> this.isKotlinOrJavaDeprecated(sourceSetData)
- is DEnum -> this.isKotlinOrJavaDeprecated(sourceSetData)
- is DFunction -> this.isKotlinOrJavaDeprecated(sourceSetData)
- is DProperty -> this.isKotlinOrJavaDeprecated(sourceSetData)
- is DEnumEntry -> this.isKotlinOrJavaDeprecated(sourceSetData)
-
- else -> false
- }
-
- private fun Documentable.hasDeprecatedChildren(sourceSetData: SourceSetData) =
- children.any { it.isDeprecated(sourceSetData) }
-
- private fun <T : Documentable> WithExtraProperties<T>.isKotlinOrJavaDeprecated(sourceSetData: SourceSetData) =
- extra[Annotations]?.content?.get(sourceSetData)?.any {
- it.dri == DRI("kotlin", "Deprecated")
- || it.dri == DRI("java.lang", "Deprecated")
- } == true
-} \ No newline at end of file
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 07636071..ed032694 100644
--- a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt
+++ b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt
@@ -7,6 +7,7 @@ import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.links.sureClassNames
import org.jetbrains.dokka.model.*
+import org.jetbrains.dokka.model.properties.WithExtraProperties
import org.jetbrains.dokka.pages.ContentKind
import org.jetbrains.dokka.pages.ContentNode
import org.jetbrains.dokka.pages.TextStyle
@@ -22,7 +23,7 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge
private val ignoredModifiers =
setOf(KotlinModifier.Open, JavaModifier.Empty, KotlinModifier.Empty, KotlinModifier.Sealed)
- override fun signature(documentable: Documentable): ContentNode = when (documentable) {
+ override fun signature(documentable: Documentable): List<ContentNode> = when (documentable) {
is DFunction -> signature(documentable)
is DProperty -> signature(documentable)
is DClasslike -> signature(documentable)
@@ -33,81 +34,114 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge
)
}
- private fun signature(e: DEnumEntry) = contentBuilder.contentFor(e, ContentKind.Symbol, setOf(TextStyle.Monospace)){
- link(e.name, e.dri)
- }
+ private fun signature(e: DEnumEntry) =
+ e.sourceSets.map {
+ contentBuilder.contentFor(
+ e,
+ ContentKind.Symbol,
+ setOf(TextStyle.Monospace) + e.stylesForDeprecated(it),
+ sourceSets = setOf(it)
+ ) {
+ link(e.name, e.dri)
+ }
+ }
private fun signature(c: DClasslike) =
- contentBuilder.contentFor(c, ContentKind.Symbol, setOf(TextStyle.Monospace)) {
- sourceSetDependentText(c.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " }
-
- if (c is DClass) {
- sourceSetDependentText(c.modifier) { it.takeIf { it !in ignoredModifiers }?.name.orEmpty() + " " }
- sourceSetDependentText(c.modifiers()) { it.toSignatureString() }
- }
+ c.sourceSets.map {
+ contentBuilder.contentFor(
+ c,
+ ContentKind.Symbol,
+ setOf(TextStyle.Monospace) + ((c as? WithExtraProperties<out Documentable>)?.stylesForDeprecated(it)
+ ?: emptySet()),
+ sourceSets = setOf(it)
+ ) {
+ sourceSetDependentText(c.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " }
+
+ if (c is DClass) {
+ sourceSetDependentText(c.modifier) { it.takeIf { it !in ignoredModifiers }?.name.orEmpty() + " " }
+ sourceSetDependentText(c.modifiers()) { it.toSignatureString() }
+ }
- when (c) {
- is DClass -> text("class ")
- is DInterface -> text("interface ")
- is DEnum -> text("enum ")
- is DObject -> text("class ")
- is DAnnotation -> text("@interface ")
- }
- link(c.name!!, c.dri)
- if (c is WithGenerics) {
- list(c.generics, prefix = "<", suffix = ">") {
- +buildSignature(it)
+ when (c) {
+ is DClass -> text("class ")
+ is DInterface -> text("interface ")
+ is DEnum -> text("enum ")
+ is DObject -> text("class ")
+ is DAnnotation -> text("@interface ")
}
- }
- if (c is WithSupertypes) {
- c.supertypes.map { (p, dris) ->
- list(dris, prefix = " extends ", sourceSets = setOf(p)) {
- link(it.sureClassNames, it, sourceSets = setOf(p))
+ link(c.name!!, c.dri)
+ if (c is WithGenerics) {
+ list(c.generics, prefix = "<", suffix = ">") {
+ +buildSignature(it)
+ }
+ }
+ if (c is WithSupertypes) {
+ c.supertypes.map { (p, dris) ->
+ list(dris, prefix = " extends ", sourceSets = setOf(p)) {
+ link(it.sureClassNames, it, sourceSets = setOf(p))
+ }
}
}
}
}
- private fun signature(p: DProperty) = contentBuilder.contentFor(p, ContentKind.Symbol, setOf(TextStyle.Monospace)) {
- group(styles = setOf(TextStyle.Block)) {
- annotationsBlock(p)
- sourceSetDependentText(p.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " }
- sourceSetDependentText(p.modifier) { it.name + " " }
- sourceSetDependentText(p.modifiers()) { it.toSignatureString() }
- signatureForProjection(p.type)
- text(nbsp.toString())
- link(p.name, p.dri)
+ private fun signature(p: DProperty) =
+ p.sourceSets.map {
+ contentBuilder.contentFor(
+ p,
+ ContentKind.Symbol,
+ setOf(TextStyle.Monospace, TextStyle.Block) + p.stylesForDeprecated(it),
+ sourceSets = setOf(it)
+ ) {
+ annotationsBlock(p)
+ sourceSetDependentText(p.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " }
+ sourceSetDependentText(p.modifier) { it.name + " " }
+ sourceSetDependentText(p.modifiers()) { it.toSignatureString() }
+ signatureForProjection(p.type)
+ text(nbsp.toString())
+ link(p.name, p.dri)
+ }
}
- }
- private fun signature(f: DFunction) = contentBuilder.contentFor(f, ContentKind.Symbol, setOf(TextStyle.Monospace)) {
- group(styles = setOf(TextStyle.Block)) {
- annotationsBlock(f)
- sourceSetDependentText(f.modifier) { it.takeIf { it !in ignoredModifiers }?.name.orEmpty() + " " }
- sourceSetDependentText(f.modifiers()) { it.toSignatureString() }
- val returnType = f.type
- signatureForProjection(returnType)
- text(nbsp.toString())
- link(f.name, f.dri)
- list(f.generics, prefix = "<", suffix = ">") {
- +buildSignature(it)
- }
- list(f.parameters, "(", ")") {
- annotationsInline(it)
- sourceSetDependentText(it.modifiers()) { it.toSignatureString() }
- signatureForProjection(it.type)
+ private fun signature(f: DFunction) =
+ f.sourceSets.map {
+ contentBuilder.contentFor(
+ f,
+ ContentKind.Symbol,
+ setOf(TextStyle.Monospace, TextStyle.Block) + f.stylesForDeprecated(it),
+ sourceSets = setOf(it)
+ ) {
+ annotationsBlock(f)
+ sourceSetDependentText(f.modifier) { it.takeIf { it !in ignoredModifiers }?.name.orEmpty() + " " }
+ sourceSetDependentText(f.modifiers()) { it.toSignatureString() }
+ val returnType = f.type
+ signatureForProjection(returnType)
text(nbsp.toString())
- link(it.name!!, it.dri)
+ link(f.name, f.dri)
+ list(f.generics, prefix = "<", suffix = ">") {
+ +buildSignature(it)
+ }
+ list(f.parameters, "(", ")") {
+ annotationsInline(it)
+ sourceSetDependentText(it.modifiers()) { it.toSignatureString() }
+ signatureForProjection(it.type)
+ text(nbsp.toString())
+ link(it.name!!, it.dri)
+ }
+
}
}
- }
- private fun signature(t: DTypeParameter) = contentBuilder.contentFor(t) {
- text(t.name.substringAfterLast("."))
- list(t.bounds, prefix = " extends ") {
- signatureForProjection(it)
+ private fun signature(t: DTypeParameter) =
+ t.sourceSets.map {
+ contentBuilder.contentFor(t, styles = t.stylesForDeprecated(it), sourceSets = setOf(it)) {
+ text(t.name.substringAfterLast("."))
+ list(t.bounds, prefix = " extends ") {
+ signatureForProjection(it)
+ }
+ }
+
}
- }
private fun PageContentBuilder.DocumentableContentBuilder.signatureForProjection(p: Projection): Unit = when (p) {
is OtherParameter -> link(p.name, p.declarationDRI)