aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/translators
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src/main/kotlin/translators')
-rw-r--r--plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt45
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt2
2 files changed, 29 insertions, 18 deletions
diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
index 8e5a1927..57d4f151 100644
--- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
@@ -12,6 +12,7 @@ import org.jetbrains.dokka.model.*
import org.jetbrains.dokka.model.Nullable
import org.jetbrains.dokka.model.TypeConstructor
import org.jetbrains.dokka.model.doc.*
+import org.jetbrains.dokka.model.properties.ExtraProperty
import org.jetbrains.dokka.model.properties.PropertyContainer
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.transformers.sources.SourceToDocumentableTranslator
@@ -140,6 +141,7 @@ private class DokkaDescriptorVisitor(
val driWithPlatform = parent.dri.withClass(descriptor.name.asString()).withEmptyInfo()
val scope = descriptor.unsubstitutedMemberScope
val isExpect = descriptor.isExpect
+ val isActual = descriptor.isActual
val info = descriptor.resolveClassDescriptionData()
return DInterface(
@@ -156,11 +158,11 @@ private class DokkaDescriptorVisitor(
generics = descriptor.declaredTypeParameters.map { it.toVariantTypeParameter() },
companion = descriptor.companion(driWithPlatform),
sourceSets = setOf(sourceSet),
- extra = PropertyContainer.withAll(
+ extra = PropertyContainer.withAll<DInterface>(
descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(),
descriptor.getAnnotations().toSourceSetDependent().toAnnotations(),
ImplementedInterfaces(info.allImplementedInterfaces.toSourceSetDependent())
- )
+ ).let { if (isExpect || isActual) it + IsExpectActual else it }
)
}
@@ -168,6 +170,7 @@ private class DokkaDescriptorVisitor(
val driWithPlatform = parent.dri.withClass(descriptor.name.asString()).withEmptyInfo()
val scope = descriptor.unsubstitutedMemberScope
val isExpect = descriptor.isExpect
+ val isActual = descriptor.isActual
val info = descriptor.resolveClassDescriptionData()
@@ -183,11 +186,11 @@ private class DokkaDescriptorVisitor(
supertypes = info.supertypes.toSourceSetDependent(),
documentation = info.docs,
sourceSets = setOf(sourceSet),
- extra = PropertyContainer.withAll(
+ extra = PropertyContainer.withAll<DObject>(
descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(),
descriptor.getAnnotations().toSourceSetDependent().toAnnotations(),
ImplementedInterfaces(info.allImplementedInterfaces.toSourceSetDependent())
- )
+ ).let { if (isExpect || isActual) it + IsExpectActual else it }
)
}
@@ -195,6 +198,7 @@ private class DokkaDescriptorVisitor(
val driWithPlatform = parent.dri.withClass(descriptor.name.asString()).withEmptyInfo()
val scope = descriptor.unsubstitutedMemberScope
val isExpect = descriptor.isExpect
+ val isActual = descriptor.isActual
val info = descriptor.resolveClassDescriptionData()
return DEnum(
@@ -212,11 +216,11 @@ private class DokkaDescriptorVisitor(
documentation = info.docs,
companion = descriptor.companion(driWithPlatform),
sourceSets = setOf(sourceSet),
- extra = PropertyContainer.withAll(
+ extra = PropertyContainer.withAll<DEnum>(
descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(),
descriptor.getAnnotations().toSourceSetDependent().toAnnotations(),
ImplementedInterfaces(info.allImplementedInterfaces.toSourceSetDependent())
- )
+ ).let { if (isExpect || isActual) it + IsExpectActual else it }
)
}
@@ -245,6 +249,8 @@ private class DokkaDescriptorVisitor(
fun annotationDescriptor(descriptor: ClassDescriptor, parent: DRIWithPlatformInfo): DAnnotation {
val driWithPlatform = parent.dri.withClass(descriptor.name.asString()).withEmptyInfo()
val scope = descriptor.unsubstitutedMemberScope
+ val isExpect = descriptor.isExpect
+ val isActual = descriptor.isActual
return DAnnotation(
dri = driWithPlatform.dri,
@@ -253,12 +259,12 @@ private class DokkaDescriptorVisitor(
classlikes = scope.classlikes(driWithPlatform),
functions = scope.functions(driWithPlatform),
properties = scope.properties(driWithPlatform),
- expectPresentInSet = null,
+ expectPresentInSet = sourceSet.takeIf { isExpect },
sourceSets = setOf(sourceSet),
- extra = PropertyContainer.withAll(
+ extra = PropertyContainer.withAll<DAnnotation>(
descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(),
descriptor.getAnnotations().toSourceSetDependent().toAnnotations()
- ),
+ ).let { if (isExpect || isActual) it + IsExpectActual else it },
companion = descriptor.companionObjectDescriptor?.let { objectDescriptor(it, driWithPlatform) },
visibility = descriptor.visibility.toDokkaVisibility().toSourceSetDependent(),
generics = descriptor.declaredTypeParameters.map { it.toVariantTypeParameter() },
@@ -271,6 +277,7 @@ private class DokkaDescriptorVisitor(
val driWithPlatform = parent.dri.withClass(descriptor.name.asString()).withEmptyInfo()
val scope = descriptor.unsubstitutedMemberScope
val isExpect = descriptor.isExpect
+ val isActual = descriptor.isActual
val info = descriptor.resolveClassDescriptionData()
val actual = descriptor.createSources()
@@ -296,17 +303,18 @@ private class DokkaDescriptorVisitor(
modifier = descriptor.modifier().toSourceSetDependent(),
companion = descriptor.companion(driWithPlatform),
sourceSets = setOf(sourceSet),
- extra = PropertyContainer.withAll(
+ extra = PropertyContainer.withAll<DClass>(
descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(),
descriptor.getAnnotations().toSourceSetDependent().toAnnotations(),
ImplementedInterfaces(info.allImplementedInterfaces.toSourceSetDependent())
- )
+ ).let { if (isExpect || isActual) it + IsExpectActual else it }
)
}
override fun visitPropertyDescriptor(descriptor: PropertyDescriptor, parent: DRIWithPlatformInfo): DProperty {
val dri = parent.dri.copy(callable = Callable.from(descriptor))
val isExpect = descriptor.isExpect
+ val isActual = descriptor.isActual
val actual = descriptor.createSources()
return DProperty(
@@ -333,7 +341,7 @@ private class DokkaDescriptorVisitor(
(descriptor.additionalExtras() + descriptor.getAnnotationsWithBackingField()
.toAdditionalExtras()).toSet().toSourceSetDependent().toAdditionalModifiers(),
descriptor.getAnnotationsWithBackingField().toSourceSetDependent().toAnnotations()
- )
+ ).let { if (isExpect || isActual) it + IsExpectActual else it }
)
}
@@ -346,6 +354,7 @@ private class DokkaDescriptorVisitor(
override fun visitFunctionDescriptor(descriptor: FunctionDescriptor, parent: DRIWithPlatformInfo): DFunction {
val (dri, inheritedFrom) = descriptor.createDRI()
val isExpect = descriptor.isExpect
+ val isActual = descriptor.isActual
val actual = descriptor.createSources()
return DFunction(
@@ -367,11 +376,11 @@ private class DokkaDescriptorVisitor(
modifier = descriptor.modifier().toSourceSetDependent(),
type = descriptor.returnType!!.toBound(),
sourceSets = setOf(sourceSet),
- extra = PropertyContainer.withAll(
+ extra = PropertyContainer.withAll<DFunction>(
InheritedFunction(inheritedFrom.toSourceSetDependent()),
descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(),
descriptor.getAnnotations().toSourceSetDependent().toAnnotations()
- )
+ ).let { if (isExpect || isActual) it + IsExpectActual else it }
)
}
@@ -380,6 +389,7 @@ private class DokkaDescriptorVisitor(
val dri = parent.dri.copy(callable = Callable.from(descriptor, name))
val actual = descriptor.createSources()
val isExpect = descriptor.isExpect
+ val isActual = descriptor.isActual
return DFunction(
dri = dri,
@@ -418,7 +428,7 @@ private class DokkaDescriptorVisitor(
if (descriptor.isPrimary) {
it + PrimaryConstructorExtra
} else it
- }
+ }.let { if (isExpect || isActual) it + IsExpectActual else it }
)
}
@@ -443,6 +453,7 @@ private class DokkaDescriptorVisitor(
val dri = parent.copy(callable = Callable.from(descriptor))
val isGetter = descriptor is PropertyGetterDescriptor
val isExpect = descriptor.isExpect
+ val isActual = descriptor.isActual
fun PropertyDescriptor.asParameter(parent: DRI) =
DParameter(
@@ -490,10 +501,10 @@ private class DokkaDescriptorVisitor(
},
sources = descriptor.createSources(),
sourceSets = setOf(sourceSet),
- extra = PropertyContainer.withAll(
+ extra = PropertyContainer.withAll<DFunction>(
descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(),
descriptor.getAnnotations().toSourceSetDependent().toAnnotations()
- )
+ ).let { if (isExpect || isActual) it + IsExpectActual else it }
)
}
diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
index 3cc77f96..615412f4 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
@@ -490,7 +490,7 @@ open class DefaultPageCreator(
header(2, name, kind = kind)
table(kind, extra = extra, styles = emptySet()) {
collection
- .groupBy { it.name }
+ .groupBy { it.name } // This groupBy should probably use LocationProvider
// This hacks displaying actual typealias signatures along classlike ones
.mapValues { if (it.value.any { it is DClasslike }) it.value.filter { it !is DTypeAlias } else it.value }
.toSortedMap(compareBy(nullsLast(String.CASE_INSENSITIVE_ORDER)) { it })