aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src/main')
-rw-r--r--plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt19
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt33
2 files changed, 32 insertions, 20 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
index f2fce191..57a3d8d1 100644
--- a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
@@ -170,6 +170,23 @@ abstract class DefaultRenderer<T>(
renderPages(newRoot)
}
}
+
+ protected fun ContentDivergentGroup.groupDivergentInstances(
+ pageContext: ContentPage,
+ beforeTransformer: (ContentDivergentInstance, ContentPage, DokkaSourceSet) -> String,
+ afterTransformer: (ContentDivergentInstance, ContentPage, DokkaSourceSet) -> String
+ ): Map<Pair<String, String>, List<Pair<ContentDivergentInstance, DokkaSourceSet>>> =
+ children.flatMap { instance ->
+ instance.sourceSets.map { sourceSet ->
+ Pair(instance, sourceSet) to Pair(
+ beforeTransformer(instance, pageContext, sourceSet),
+ afterTransformer(instance, pageContext, sourceSet)
+ )
+ }
+ }.groupBy(
+ Pair<Pair<ContentDivergentInstance, DokkaSourceSet>, Pair<String, String>>::second,
+ Pair<Pair<ContentDivergentInstance, DokkaSourceSet>, Pair<String, String>>::first
+ )
}
-fun ContentPage.sourceSets() = this.content.sourceSets
+fun ContentPage.sourceSets() = this.content.sourceSets \ No newline at end of file
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index a950667f..595dc8d2 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -222,26 +222,21 @@ open class HtmlRenderer(
}
override fun FlowContent.buildDivergent(node: ContentDivergentGroup, pageContext: ContentPage) {
+
val distinct =
- node.children.flatMap { instance ->
- instance.sourceSets.map { sourceSet ->
- Pair(instance, sourceSet) to Pair(
- createHTML(prettyPrint = false).div {
- instance.before?.let { before ->
- buildContentNode(before, pageContext, setOf(sourceSet))
- }
- }.stripDiv(),
- createHTML(prettyPrint = false).div {
- instance.after?.let { after ->
- buildContentNode(after, pageContext, setOf(sourceSet))
- }
- }.stripDiv()
- )
- }
- }.groupBy(
- Pair<Pair<ContentDivergentInstance, DokkaSourceSet>, Pair<String, String>>::second,
- Pair<Pair<ContentDivergentInstance, DokkaSourceSet>, Pair<String, String>>::first
- )
+ node.groupDivergentInstances(pageContext, { instance, contentPage, sourceSet ->
+ createHTML(prettyPrint = false).div {
+ instance.before?.let { before ->
+ buildContentNode(before, pageContext, setOf(sourceSet))
+ }
+ }.stripDiv()
+ }, { instance, contentPage, sourceSet ->
+ createHTML(prettyPrint = false).div {
+ instance.after?.let { after ->
+ buildContentNode(after, pageContext, setOf(sourceSet))
+ }
+ }.stripDiv()
+ })
distinct.forEach {
val groupedDivergent = it.value.groupBy { it.second }