aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-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
-rw-r--r--plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt1
-rw-r--r--plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt1
-rw-r--r--plugins/base/src/test/kotlin/markdown/LinkTest.kt2
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocContentNodes.kt7
8 files changed, 53 insertions, 7 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)
diff --git a/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt b/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt
index 4ac5717d..4f2bd8dc 100644
--- a/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt
+++ b/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt
@@ -9,7 +9,6 @@ import org.jetbrains.dokka.model.doc.Param
import org.jetbrains.dokka.model.doc.Text
import org.jetbrains.dokka.pages.ContentPage
import org.jetbrains.dokka.pages.MemberPageNode
-import org.jetbrains.dokka.pages.dfs
import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
import org.junit.jupiter.api.Test
diff --git a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt
index f93678a4..42d10549 100644
--- a/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt
+++ b/plugins/base/src/test/kotlin/linkableContent/LinkableContentTest.kt
@@ -5,6 +5,7 @@ import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.transformers.pages.samples.DefaultSamplesTransformer
import org.jetbrains.dokka.base.transformers.pages.sourcelinks.SourceLinksTransformer
import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder
+import org.jetbrains.dokka.model.dfs
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.plugability.plugin
import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest
diff --git a/plugins/base/src/test/kotlin/markdown/LinkTest.kt b/plugins/base/src/test/kotlin/markdown/LinkTest.kt
index a6333c5a..32cf01a8 100644
--- a/plugins/base/src/test/kotlin/markdown/LinkTest.kt
+++ b/plugins/base/src/test/kotlin/markdown/LinkTest.kt
@@ -1,9 +1,9 @@
package markdown
+import org.jetbrains.dokka.model.dfs
import org.jetbrains.dokka.pages.ClasslikePageNode
import org.jetbrains.dokka.pages.ContentDRILink
import org.jetbrains.dokka.pages.MemberPageNode
-import org.jetbrains.dokka.pages.dfs
import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertNotNull
diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocContentNodes.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocContentNodes.kt
index 2c9ee013..5816ad3c 100644
--- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocContentNodes.kt
+++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocContentNodes.kt
@@ -17,6 +17,10 @@ abstract class JavadocContentNode(
override val style: Set<Style> = emptySet()
override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
override fun withNewExtras(newExtras: PropertyContainer<ContentNode>): ContentNode = this
+
+ // TODO: Support needed?
+ override fun withSourceSets(sourceSets: Set<ContentSourceSet>): JavadocContentNode = this
+
}
interface JavadocList {
@@ -41,6 +45,9 @@ class EmptyNode(
override fun withNewExtras(newExtras: PropertyContainer<ContentNode>): ContentNode =
EmptyNode(dci.dri.first(), dci.kind, sourceSets, newExtras)
+ override fun withSourceSets(sourceSets: Set<ContentSourceSet>): ContentNode =
+ EmptyNode(dci.dri.first(), dci.kind, sourceSets, extra)
+
override fun hasAnyContent(): Boolean = false
}