diff options
4 files changed, 20 insertions, 17 deletions
diff --git a/core/src/main/kotlin/model/documentableProperties.kt b/core/src/main/kotlin/model/documentableProperties.kt index 699a1df1..1a0c6303 100644 --- a/core/src/main/kotlin/model/documentableProperties.kt +++ b/core/src/main/kotlin/model/documentableProperties.kt @@ -4,11 +4,11 @@ import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.properties.ExtraProperty import org.jetbrains.dokka.model.properties.MergeStrategy -data class InheritedFunction(val inheritedFrom: DRI?): ExtraProperty<DFunction> { +data class InheritedFunction(val inheritedFrom: SourceSetDependent<DRI?>): ExtraProperty<DFunction> { companion object : ExtraProperty.Key<DFunction, InheritedFunction> { - override fun mergeStrategyFor(left: InheritedFunction, right: InheritedFunction) = MergeStrategy.Fail { - throw IllegalArgumentException("Function inheritance should be consistent!") - } + override fun mergeStrategyFor(left: InheritedFunction, right: InheritedFunction) = MergeStrategy.Replace( + InheritedFunction(left.inheritedFrom + right.inheritedFrom) + ) } val isInherited: Boolean @@ -17,11 +17,11 @@ data class InheritedFunction(val inheritedFrom: DRI?): ExtraProperty<DFunction> override val key: ExtraProperty.Key<DFunction, *> = InheritedFunction } -data class ImplementedInterfaces(val interfaces: List<DRI>): ExtraProperty<Documentable> { +data class ImplementedInterfaces(val interfaces: SourceSetDependent<List<DRI>>): ExtraProperty<Documentable> { companion object : ExtraProperty.Key<Documentable, ImplementedInterfaces> { - override fun mergeStrategyFor(left: ImplementedInterfaces, right: ImplementedInterfaces) = MergeStrategy.Fail { - throw IllegalArgumentException("Implemented interfaces should be consistent!") - } + override fun mergeStrategyFor(left: ImplementedInterfaces, right: ImplementedInterfaces) = MergeStrategy.Replace( + ImplementedInterfaces(left.interfaces + right.interfaces) + ) } override val key: ExtraProperty.Key<Documentable, *> = ImplementedInterfaces diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index 4f292ca1..4764fbcb 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -148,7 +148,7 @@ private class DokkaDescriptorVisitor( extra = PropertyContainer.withAll( descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(), descriptor.getAnnotations().toSourceSetDependent().toAnnotations(), - ImplementedInterfaces(info.interfaces) + ImplementedInterfaces(info.interfaces.toSourceSetDependent()) ) ) } @@ -175,7 +175,7 @@ private class DokkaDescriptorVisitor( extra = PropertyContainer.withAll( descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(), descriptor.getAnnotations().toSourceSetDependent().toAnnotations(), - ImplementedInterfaces(info.interfaces) + ImplementedInterfaces(info.interfaces.toSourceSetDependent()) ) ) } @@ -204,7 +204,7 @@ private class DokkaDescriptorVisitor( extra = PropertyContainer.withAll( descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(), descriptor.getAnnotations().toSourceSetDependent().toAnnotations(), - ImplementedInterfaces(info.interfaces) + ImplementedInterfaces(info.interfaces.toSourceSetDependent()) ) ) } @@ -288,7 +288,7 @@ private class DokkaDescriptorVisitor( extra = PropertyContainer.withAll( descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(), descriptor.getAnnotations().toSourceSetDependent().toAnnotations(), - ImplementedInterfaces(info.interfaces) + ImplementedInterfaces(info.interfaces.toSourceSetDependent()) ) ) } @@ -356,7 +356,7 @@ private class DokkaDescriptorVisitor( type = descriptor.returnType!!.toBound(), sourceSets = setOf(sourceSet), extra = PropertyContainer.withAll( - InheritedFunction(inheritedFrom), + InheritedFunction(inheritedFrom.toSourceSetDependent()), descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(), descriptor.getAnnotations().toSourceSetDependent().toAnnotations() ) diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt index 8b397859..30204d01 100644 --- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt @@ -154,7 +154,7 @@ object DefaultPsiToDocumentableTranslator : SourceToDocumentableTranslator { val visibility = getVisibility().toSourceSetDependent() val ancestors = ancestorsSet.toList().map { it.dri }.toSourceSetDependent() val modifiers = getModifier().toSourceSetDependent() - val implementedInterfacesExtra = ImplementedInterfaces(ancestorsSet.filter { it.isInterface }.map { it.dri }.toList()) + val implementedInterfacesExtra = ImplementedInterfaces(ancestorsSet.filter { it.isInterface }.map { it.dri }.toList().toSourceSetDependent()) return when { isAnnotationType -> DAnnotation( @@ -276,7 +276,7 @@ object DefaultPsiToDocumentableTranslator : SourceToDocumentableTranslator { setOf(sourceSetData), psi.additionalExtras().let { PropertyContainer.withAll( - InheritedFunction(inheritedFrom), + InheritedFunction(inheritedFrom.toSourceSetDependent()), it.toSourceSetDependent().toAdditionalModifiers(), (psi.annotations.toList().toListOfAnnotations() + it.toListOfAnnotations()).toSourceSetDependent() .toAnnotations() diff --git a/plugins/javadoc/src/main/kotlin/javadoc/KorteJavadocRenderer.kt b/plugins/javadoc/src/main/kotlin/javadoc/KorteJavadocRenderer.kt index f0835270..22b0225b 100644 --- a/plugins/javadoc/src/main/kotlin/javadoc/KorteJavadocRenderer.kt +++ b/plugins/javadoc/src/main/kotlin/javadoc/KorteJavadocRenderer.kt @@ -6,6 +6,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking +import org.jetbrains.dokka.Platform import org.jetbrains.dokka.base.renderers.OutputWriter import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.links.sureClassNames @@ -273,7 +274,8 @@ class KorteJavadocRenderer(val outputWriter: OutputWriter, val context: DokkaCon ) + renderJavadocContentNode(node.content) private fun renderImplementedInterfaces(node: JavadocClasslikePageNode) = - node.extras[ImplementedInterfaces]?.interfaces?.map { it.displayable() }.orEmpty() + node.extras[ImplementedInterfaces]?.interfaces?.entries?.firstOrNull { it.key.platform == Platform.jvm }?.value?.map { it.displayable() } // TODO: REMOVE HARDCODED JVM DEPENDENCY + .orEmpty() private fun renderClasslikeMethods(nodes: List<JavadocFunctionNode>): TemplateMap { val (inherited, own) = nodes.partition { it.extras[InheritedFunction]?.isInherited ?: false } @@ -292,7 +294,8 @@ class KorteJavadocRenderer(val outputWriter: OutputWriter, val context: DokkaCon private fun renderInheritedMethod(node: JavadocFunctionNode): TemplateMap { val inheritedFrom = node.extras[InheritedFunction]?.inheritedFrom return mapOf( - "inheritedFrom" to inheritedFrom?.displayable().orEmpty(), + "inheritedFrom" to inheritedFrom?.entries?.firstOrNull { it.key.platform == Platform.jvm }?.value?.displayable() // TODO: REMOVE HARDCODED JVM DEPENDENCY + .orEmpty(), "name" to node.name ) } |