aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src/main/kotlin')
-rw-r--r--plugins/base/src/main/kotlin/DokkaBase.kt9
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt1
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt3
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/merger/SourceSetMergingPageTransformer.kt36
4 files changed, 44 insertions, 5 deletions
diff --git a/plugins/base/src/main/kotlin/DokkaBase.kt b/plugins/base/src/main/kotlin/DokkaBase.kt
index 20769d07..cf268ec1 100644
--- a/plugins/base/src/main/kotlin/DokkaBase.kt
+++ b/plugins/base/src/main/kotlin/DokkaBase.kt
@@ -19,10 +19,7 @@ import org.jetbrains.dokka.base.transformers.documentables.ReportUndocumentedTra
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
-import org.jetbrains.dokka.base.transformers.pages.merger.FallbackPageMergerStrategy
-import org.jetbrains.dokka.base.transformers.pages.merger.PageMerger
-import org.jetbrains.dokka.base.transformers.pages.merger.PageMergerStrategy
-import org.jetbrains.dokka.base.transformers.pages.merger.SameMethodNamePageMergerStrategy
+import org.jetbrains.dokka.base.transformers.pages.merger.*
import org.jetbrains.dokka.base.transformers.pages.samples.DefaultSamplesTransformer
import org.jetbrains.dokka.base.transformers.pages.sourcelinks.SourceLinksTransformer
import org.jetbrains.dokka.base.translators.descriptors.DefaultDescriptorToDocumentableTranslator
@@ -129,6 +126,10 @@ class DokkaBase : DokkaPlugin() {
CoreExtensions.pageTransformer providing { ctx -> PageMerger(ctx[pageMergerStrategy]) }
}
+ val sourceSetMerger by extending {
+ CoreExtensions.pageTransformer providing ::SourceSetMergingPageTransformer
+ }
+
val fallbackMerger by extending {
pageMergerStrategy providing { ctx -> FallbackPageMergerStrategy(ctx.logger) }
}
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index c533836a..8baf70a5 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -10,6 +10,7 @@ import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.renderers.DefaultRenderer
import org.jetbrains.dokka.base.renderers.TabSortingStrategy
import org.jetbrains.dokka.links.DRI
+import org.jetbrains.dokka.model.dfs
import org.jetbrains.dokka.model.properties.PropertyContainer
import org.jetbrains.dokka.model.withDescendants
import org.jetbrains.dokka.pages.*
diff --git a/plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt b/plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt
index d81f131b..4eacf359 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/merger/SameMethodNamePageMergerStrategy.kt
@@ -1,5 +1,6 @@
package org.jetbrains.dokka.base.transformers.pages.merger
+import org.jetbrains.dokka.model.dfs
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.utilities.DokkaLogger
@@ -37,4 +38,4 @@ class SameMethodNamePageMergerStrategy(val logger: DokkaLogger) : PageMergerStra
)
}
}
-} \ No newline at end of file
+}
diff --git a/plugins/base/src/main/kotlin/transformers/pages/merger/SourceSetMergingPageTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/merger/SourceSetMergingPageTransformer.kt
new file mode 100644
index 00000000..aaf4b5c3
--- /dev/null
+++ b/plugins/base/src/main/kotlin/transformers/pages/merger/SourceSetMergingPageTransformer.kt
@@ -0,0 +1,36 @@
+package org.jetbrains.dokka.base.transformers.pages.merger
+
+import org.jetbrains.dokka.Platform
+import org.jetbrains.dokka.pages.*
+import org.jetbrains.dokka.plugability.DokkaContext
+import org.jetbrains.dokka.transformers.pages.PageTransformer
+
+class SourceSetMergingPageTransformer(context: DokkaContext) : PageTransformer {
+
+ private val mergedSourceSets = context.configuration.sourceSets.toContentSourceSets()
+ .associateBy { sourceSet -> sourceSet.key }
+
+ override fun invoke(input: RootPageNode): RootPageNode {
+ return input.transformContentPagesTree { contentPage ->
+ val content: ContentNode = contentPage.content
+ val newContent = transformWithMergedSourceSets(content)
+ contentPage.modified(content = newContent)
+ }
+ }
+
+ private fun transformWithMergedSourceSets(
+ contentNode: ContentNode
+ ): ContentNode {
+ val mergedSourceSets = contentNode.sourceSets.map { mergedSourceSets.getValue(it.key) }.toSet()
+ return when (contentNode) {
+ is ContentComposite -> contentNode
+ .transformChildren(::transformWithMergedSourceSets)
+ .withSourceSets(mergedSourceSets)
+ else -> contentNode.withSourceSets(mergedSourceSets.toSet())
+ }
+ }
+}
+
+private val ContentSourceSet.key get() = SourceSetMergingKey(displayName, analysisPlatform)
+
+private data class SourceSetMergingKey(private val displayName: String, private val platform: Platform)