aboutsummaryrefslogtreecommitdiff
path: root/plugins/base
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-08-13 17:43:08 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-08-17 11:52:28 +0200
commitcc2c4f0033cfa2f1ebfa0b8aeb01b65823577c9a (patch)
treed1e0e25eb5dc85132b8036b4f20314fe81d6f0d7 /plugins/base
parent5a7e14eaaa4278343ff628c692d475be9732c94e (diff)
downloaddokka-cc2c4f0033cfa2f1ebfa0b8aeb01b65823577c9a.tar.gz
dokka-cc2c4f0033cfa2f1ebfa0b8aeb01b65823577c9a.tar.bz2
dokka-cc2c4f0033cfa2f1ebfa0b8aeb01b65823577c9a.zip
HtmlRenderer: Fix usage of sourceSetDependencyMap
Diffstat (limited to 'plugins/base')
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt21
1 files changed, 13 insertions, 8 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index 8baf70a5..71a28345 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -5,6 +5,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.html.*
import kotlinx.html.stream.createHTML
+import org.jetbrains.dokka.DokkaSourceSetID
import org.jetbrains.dokka.Platform
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.renderers.DefaultRenderer
@@ -26,11 +27,14 @@ open class HtmlRenderer(
context: DokkaContext
) : DefaultRenderer<FlowContent>(context) {
- private val sourceSetDependencyMap = context.configuration.sourceSets.map { sourceSet ->
- sourceSet to context.configuration.sourceSets.filter { sourceSet.dependentSourceSets.contains(it.sourceSetID) }
- }.toMap()
+ private val sourceSetDependencyMap: Map<DokkaSourceSetID, List<DokkaSourceSetID>> =
+ context.configuration.sourceSets.map { sourceSet ->
+ sourceSet.sourceSetID to context.configuration.sourceSets
+ .map { it.sourceSetID }
+ .filter { it in sourceSet.dependentSourceSets }
+ }.toMap()
- private val isMultiplatform by lazy {
+ private val shouldShowSourceSetBubbles by lazy {
sourceSetDependencyMap.size > 1
}
@@ -105,7 +109,7 @@ open class HtmlRenderer(
}
private fun FlowContent.filterButtons(page: ContentPage) {
- if (isMultiplatform) {
+ if (shouldShowSourceSetBubbles) {
div(classes = "filter-section") {
id = "filter-section"
page.content.withDescendants().flatMap { it.sourceSets }.distinct().forEach {
@@ -223,8 +227,9 @@ open class HtmlRenderer(
Pair<ContentSourceSet, String>::second,
Pair<ContentSourceSet, String>::first
).entries.flatMap { (html, sourceSets) ->
- sourceSets.filterNot {
- sourceSetDependencyMap[it].orEmpty().any { dependency -> sourceSets.contains(dependency) }
+ sourceSets.filterNot { sourceSet ->
+ sourceSet.sourceSetIDs.all.flatMap { sourceSetDependencyMap[it].orEmpty() }
+ .any { sourceSetId -> sourceSetId in sourceSets.sourceSetIDs }
}.map {
it to createHTML(prettyPrint = false).div(classes = "content sourceset-depenent-content") {
if (counter++ == 0) attributes["data-active"] = ""
@@ -410,7 +415,7 @@ open class HtmlRenderer(
}
private fun FlowContent.createPlatformTagBubbles(sourceSets: List<ContentSourceSet>) {
- if (isMultiplatform) {
+ if (shouldShowSourceSetBubbles) {
div("platform-tags") {
sourceSets.forEach {
div("platform-tag") {