diff options
-rw-r--r-- | core/src/main/kotlin/CoreExtensions.kt | 4 | ||||
-rw-r--r-- | core/src/main/kotlin/DokkaGenerator.kt | 2 | ||||
-rw-r--r-- | core/src/main/kotlin/plugability/DefaultExtensions.kt | 2 | ||||
-rw-r--r-- | core/src/main/kotlin/transformers/documentation/DocumentableMerger.kt (renamed from core/src/main/kotlin/transformers/documentation/DocumentationNodeMerger.kt) | 2 | ||||
-rw-r--r-- | core/src/main/kotlin/utilities/genericUtils.kt | 3 | ||||
-rw-r--r-- | plugins/base/src/main/kotlin/DokkaBase.kt | 5 | ||||
-rw-r--r-- | plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt (renamed from core/src/main/kotlin/transformers/documentation/DefaultDocumentationNodeMerger.kt) | 10 |
7 files changed, 18 insertions, 10 deletions
diff --git a/core/src/main/kotlin/CoreExtensions.kt b/core/src/main/kotlin/CoreExtensions.kt index 1364f1c1..47f2e4c1 100644 --- a/core/src/main/kotlin/CoreExtensions.kt +++ b/core/src/main/kotlin/CoreExtensions.kt @@ -6,7 +6,7 @@ import org.jetbrains.dokka.renderers.Renderer import org.jetbrains.dokka.renderers.OutputWriter import org.jetbrains.dokka.resolvers.LocationProviderFactory import org.jetbrains.dokka.transformers.descriptors.DescriptorToDocumentationTranslator -import org.jetbrains.dokka.transformers.documentation.DocumentationNodeMerger +import org.jetbrains.dokka.transformers.documentation.DocumentableMerger import org.jetbrains.dokka.transformers.documentation.DocumentationNodeTransformer import org.jetbrains.dokka.transformers.documentation.DocumentationToPageTranslator import org.jetbrains.dokka.transformers.pages.PageMergerStrategy @@ -22,7 +22,7 @@ import kotlin.reflect.KProperty object CoreExtensions { val descriptorToDocumentationTranslator by coreExtension<DescriptorToDocumentationTranslator>() val psiToDocumentationTranslator by coreExtension<PsiToDocumentationTranslator>() - val documentationMerger by coreExtension<DocumentationNodeMerger>() + val documentableMerger by coreExtension<DocumentableMerger>() val documentationTransformer by coreExtension<DocumentationNodeTransformer>() val commentsToContentConverter by coreExtension<CommentsToContentConverter>() val documentationToPageTranslator by coreExtension<DocumentationToPageTranslator>() diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt index 573ba13e..1829c9e4 100644 --- a/core/src/main/kotlin/DokkaGenerator.kt +++ b/core/src/main/kotlin/DokkaGenerator.kt @@ -78,7 +78,7 @@ class DokkaGenerator( fun mergeDocumentationModels( modulesFromPlatforms: List<Module>, context: DokkaContext - ) = context.single(CoreExtensions.documentationMerger).invoke(modulesFromPlatforms, context) + ) = context.single(CoreExtensions.documentableMerger).invoke(modulesFromPlatforms, context) fun transformDocumentationModel( documentationModel: Module, diff --git a/core/src/main/kotlin/plugability/DefaultExtensions.kt b/core/src/main/kotlin/plugability/DefaultExtensions.kt index 70a7e4db..c1a72c74 100644 --- a/core/src/main/kotlin/plugability/DefaultExtensions.kt +++ b/core/src/main/kotlin/plugability/DefaultExtensions.kt @@ -6,7 +6,6 @@ import org.jetbrains.dokka.renderers.FileWriter import org.jetbrains.dokka.renderers.OutputWriter import org.jetbrains.dokka.renderers.html.HtmlRenderer import org.jetbrains.dokka.resolvers.DefaultLocationProviderFactory -import org.jetbrains.dokka.transformers.documentation.DefaultDocumentationNodeMerger import org.jetbrains.dokka.transformers.documentation.DefaultDocumentationToPageTranslator import org.jetbrains.dokka.transformers.pages.DefaultPageMergerStrategy import org.jetbrains.dokka.transformers.psi.DefaultPsiToDocumentationTranslator @@ -28,7 +27,6 @@ internal object DefaultExtensions { internal fun <T : Any, E : ExtensionPoint<T>> get(point: E, fullContext: DokkaContext): List<T> = when (point) { CoreExtensions.psiToDocumentationTranslator -> DefaultPsiToDocumentationTranslator - CoreExtensions.documentationMerger -> DefaultDocumentationNodeMerger CoreExtensions.commentsToContentConverter -> converter.get(fullContext) CoreExtensions.documentationToPageTranslator -> DefaultDocumentationToPageTranslator CoreExtensions.pageTransformer -> DefaultPageNodeMerger(fullContext) diff --git a/core/src/main/kotlin/transformers/documentation/DocumentationNodeMerger.kt b/core/src/main/kotlin/transformers/documentation/DocumentableMerger.kt index 25be625e..5a17bc24 100644 --- a/core/src/main/kotlin/transformers/documentation/DocumentationNodeMerger.kt +++ b/core/src/main/kotlin/transformers/documentation/DocumentableMerger.kt @@ -3,6 +3,6 @@ package org.jetbrains.dokka.transformers.documentation import org.jetbrains.dokka.model.Module import org.jetbrains.dokka.plugability.DokkaContext -interface DocumentationNodeMerger { +interface DocumentableMerger { operator fun invoke(modules: Collection<Module>, context: DokkaContext): Module }
\ No newline at end of file diff --git a/core/src/main/kotlin/utilities/genericUtils.kt b/core/src/main/kotlin/utilities/genericUtils.kt new file mode 100644 index 00000000..e94e4e8f --- /dev/null +++ b/core/src/main/kotlin/utilities/genericUtils.kt @@ -0,0 +1,3 @@ +package org.jetbrains.dokka.utilities + +fun <T : Any, S : Any> Pair<T?, S?>.pullOutNull(): Pair<T, S>? = first?.let { f -> second?.let { s -> f to s } }
\ No newline at end of file diff --git a/plugins/base/src/main/kotlin/DokkaBase.kt b/plugins/base/src/main/kotlin/DokkaBase.kt index 648acfbb..b18e2ad5 100644 --- a/plugins/base/src/main/kotlin/DokkaBase.kt +++ b/plugins/base/src/main/kotlin/DokkaBase.kt @@ -2,10 +2,15 @@ package org.jetbrains.dokka.base import org.jetbrains.dokka.CoreExtensions import org.jetbrains.dokka.base.transformers.descriptors.DefaultDescriptorToDocumentationTranslator +import org.jetbrains.dokka.base.transformers.documentables.DefaultDocumentableMerger import org.jetbrains.dokka.plugability.DokkaPlugin class DokkaBase: DokkaPlugin() { val defaultDescriptorToDocumentationTranslator by extending(isFallback = true) { CoreExtensions.descriptorToDocumentationTranslator providing ::DefaultDescriptorToDocumentationTranslator } + + val defaultDocumentableMerger by extending(isFallback = true) { + CoreExtensions.documentableMerger with DefaultDocumentableMerger + } }
\ No newline at end of file diff --git a/core/src/main/kotlin/transformers/documentation/DefaultDocumentationNodeMerger.kt b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt index 0d7fa249..f2e6f177 100644 --- a/core/src/main/kotlin/transformers/documentation/DefaultDocumentationNodeMerger.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt @@ -1,11 +1,13 @@ -package org.jetbrains.dokka.transformers.documentation +package org.jetbrains.dokka.base.transformers.documentables import org.jetbrains.dokka.model.* import org.jetbrains.dokka.model.Enum import org.jetbrains.dokka.model.Function import org.jetbrains.dokka.plugability.DokkaContext +import org.jetbrains.dokka.transformers.documentation.DocumentableMerger +import org.jetbrains.dokka.utilities.pullOutNull -internal object DefaultDocumentationNodeMerger : DocumentationNodeMerger { +internal object DefaultDocumentableMerger : DocumentableMerger { override fun invoke(modules: Collection<Module>, context: DokkaContext): Module { if (!modules.all { it.name == modules.first().name }) context.logger.error("All module names need to be the same") @@ -49,7 +51,7 @@ fun Function.mergeWith(other: Function): Function = Function( name, returnType, isConstructor, - if (receiver != null && other.receiver != null) receiver.mergeWith(other.receiver) else null, + (receiver to other.receiver).pullOutNull()?.let { (f, s) -> f.mergeWith(s) }, merge(parameters + other.parameters, Parameter::mergeWith), expected?.mergeWith(other.expected), (actual + other.actual).merge(), @@ -59,7 +61,7 @@ fun Function.mergeWith(other: Function): Function = Function( fun Property.mergeWith(other: Property) = Property( dri, name, - if (receiver != null && other.receiver != null) receiver.mergeWith(other.receiver) else null, + (receiver to other.receiver).pullOutNull()?.let { (f, s) -> f.mergeWith(s) }, expected?.mergeWith(other.expected), (actual + other.actual).merge(), accessors = (this.accessors + other.accessors).distinct(), |