aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt2
-rw-r--r--plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt55
-rw-r--r--plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt1
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt2
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt8
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt9
6 files changed, 63 insertions, 14 deletions
diff --git a/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt b/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt
index f8141110..a7fc7570 100644
--- a/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt
+++ b/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt
@@ -13,7 +13,7 @@ interface JvmSignatureUtils {
fun <T : Documentable> WithExtraProperties<T>.modifiers(): SourceSetDependent<Set<ExtraModifiers>>
- fun Set<ExtraModifiers>.toSignatureString(): String =
+ fun Collection<ExtraModifiers>.toSignatureString(): String =
joinToString("") { it.name.toLowerCase() + " " }
fun <T : Documentable> WithExtraProperties<T>.annotations(): SourceSetDependent<List<Annotations.Annotation>> =
diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
index ab3056ec..faca95ee 100644
--- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
+++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
@@ -1,5 +1,6 @@
package org.jetbrains.dokka.base.signatures
+import org.jetbrains.dokka.Platform
import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter
import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder
import org.jetbrains.dokka.links.*
@@ -19,6 +20,13 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
private val ignoredVisibilities = setOf(JavaVisibility.Public, KotlinVisibility.Public)
private val ignoredModifiers = setOf(JavaModifier.Final, KotlinModifier.Final)
+ private val ignoredExtraModifiers = setOf(
+ ExtraModifiers.KotlinOnlyModifiers.TailRec,
+ ExtraModifiers.KotlinOnlyModifiers.External
+ )
+ private val platformSpecificModifiers : Map<ExtraModifiers, Set<Platform>> = mapOf(
+ ExtraModifiers.KotlinOnlyModifiers.External to setOf(Platform.js)
+ )
override fun signature(documentable: Documentable): ContentNode = when (documentable) {
is DFunction -> functionSignature(documentable)
@@ -32,6 +40,20 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
)
}
+ private fun <T> PageContentBuilder.DocumentableContentBuilder.processExtraModifiers (t: T)
+ where T: Documentable, T: WithExtraProperties<T> {
+ sourceSetDependentText(
+ t.modifiers()
+ .mapValues { entry ->
+ entry.value.filter {
+ it !in ignoredExtraModifiers || entry.key.platform in (platformSpecificModifiers[it] ?: emptySet())
+ }
+ }
+ ) {
+ it.toSignatureString()
+ }
+ }
+
private fun signature(e: DEnumEntry) =
contentBuilder.contentFor(
e,
@@ -96,11 +118,26 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
}
}
when (c) {
- is DClass -> text("class ")
- is DInterface -> text("interface ")
- is DEnum -> text("enum ")
- is DObject -> text("object ")
- is DAnnotation -> text("annotation class ")
+ is DClass -> {
+ processExtraModifiers(c)
+ text("class ")
+ }
+ is DInterface -> {
+ processExtraModifiers(c)
+ text("interface ")
+ }
+ is DEnum -> {
+ processExtraModifiers(c)
+ text("enum ")
+ }
+ is DObject -> {
+ processExtraModifiers(c)
+ text("object ")
+ }
+ is DAnnotation -> {
+ processExtraModifiers(c)
+ text("annotation class ")
+ }
}
link(c.name!!, c.dri)
if (c is WithGenerics) {
@@ -146,7 +183,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
if (it is JavaModifier.Empty) KotlinModifier.Open else it
}?.name?.let { "$it " } ?: ""
}
- sourceSetDependentText(p.modifiers()) { it.toSignatureString() }
+ processExtraModifiers(p)
p.setter?.let { text("var ") } ?: text("val ")
list(p.generics, prefix = "<", suffix = "> ") {
+buildSignature(it)
@@ -169,7 +206,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
if (it is JavaModifier.Empty) KotlinModifier.Open else it
}?.name?.let { "$it " } ?: ""
}
- sourceSetDependentText(f.modifiers()) { it.toSignatureString() }
+ processExtraModifiers(f)
text("fun ")
list(f.generics, prefix = "<", suffix = "> ") {
+buildSignature(it)
@@ -182,7 +219,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
text("(")
list(f.parameters) {
annotationsInline(it)
- sourceSetDependentText(it.modifiers()) { it.toSignatureString() }
+ processExtraModifiers(it)
text(it.name!!)
text(": ")
signatureForProjection(it.type)
@@ -211,7 +248,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
sourceSets = platforms.toSet()
) {
sourceSetDependentText(t.visibility) { it.takeIf { it !in ignoredVisibilities }?.name?.let { "$it " } ?: "" }
- sourceSetDependentText(t.modifiers()) { it.toSignatureString() }
+ processExtraModifiers(t)
text("typealias ")
signatureForProjection(t.type)
text(" = ")
diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt
index 1f323473..c8ff3fac 100644
--- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt
+++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt
@@ -12,6 +12,7 @@ object KotlinSignatureUtils : JvmSignatureUtils {
private val listBrackets = Pair('[', ']')
private val classExtension = "::class"
+
override fun PageContentBuilder.DocumentableContentBuilder.annotationsBlock(d: Documentable) =
annotationsBlockWithIgnored(d, emptySet(), strategy, listBrackets, classExtension)
diff --git a/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt
index d987a5d5..8113d277 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt
@@ -61,7 +61,7 @@ class SourceLinksTransformer(val context: DokkaContext, val builder: PageContent
+ContentTable(
emptyList(),
sources.map {
- buildGroup(node.dri, setOf(it.first)) {
+ buildGroup(node.dri, setOf(it.first), kind = ContentKind.Source) {
+link("(source)", it.second)
}
},
diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
index b69f60d2..bc3f79c8 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
@@ -180,7 +180,7 @@ open class DefaultPageCreator(
}
}
if (c is DEnum) {
- block("Entries", 2, ContentKind.Classlikes, c.entries, c.sourceSets.toSet(), extra = mainExtra + SimpleAttr.header("Entries"), styles = emptySet()) {
+ block("Entries", 2, ContentKind.Classlikes, c.entries, c.sourceSets.toSet(), needsSorting = false, extra = mainExtra + SimpleAttr.header("Entries"), styles = emptySet()) {
link(it.name, it.dri)
sourceSetDependentHint(it.dri, it.sourceSets.toSet(), kind = ContentKind.SourceSetDependantHint) {
contentForBrief(it)
@@ -201,6 +201,7 @@ open class DefaultPageCreator(
(this[T::class] as List<Pair<SourceSetData, T>>?)
?.groupBy { it.second.name }
?.mapValues { (_, v) -> v.toMap() }
+ ?.toSortedMap(String.CASE_INSENSITIVE_ORDER)
.orEmpty()
private inline fun <reified T : TagWrapper> GroupedTags.isNotEmptyForTag(): Boolean =
@@ -377,7 +378,10 @@ open class DefaultPageCreator(
if (collection.any()) {
header(2, name)
table(kind, extra = extra) {
- collection.groupBy { it.name }.map { (elementName, elements) -> // This groupBy should probably use LocationProvider
+ collection
+ .groupBy { it.name }
+ .toSortedMap(compareBy(nullsLast(String.CASE_INSENSITIVE_ORDER)){it})
+ .map { (elementName, elements) -> // This groupBy should probably use LocationProvider
buildGroup(elements.map { it.dri }.toSet(), elements.flatMap { it.sourceSets }.toSet(), kind = kind) {
link(elementName.orEmpty(), elements.first().dri, kind = kind)
divergentGroup(
diff --git a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt
index cbae588f..9d10620e 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt
@@ -172,13 +172,20 @@ open class PageContentBuilder(
styles: Set<Style> = mainStyles,
extra: PropertyContainer<ContentNode> = mainExtra,
renderWhenEmpty: Boolean = false,
+ needsSorting: Boolean = true,
operation: DocumentableContentBuilder.(T) -> Unit
) {
if (renderWhenEmpty || elements.any()) {
header(level, name) { }
contents += ContentTable(
emptyList(),
- elements.map {
+ elements
+ .let{
+ if (needsSorting)
+ it.sortedWith(compareBy(nullsLast(String.CASE_INSENSITIVE_ORDER)){ it.name })
+ else it
+ }
+ .map {
buildGroup(setOf(it.dri), it.sourceSets.toSet(), kind, styles, extra) {
operation(it)
}