diff options
author | sebastian.sellmair <sebastian.sellmair@jetbrains.com> | 2020-08-13 18:18:20 +0200 |
---|---|---|
committer | Sebastian Sellmair <34319766+sellmair@users.noreply.github.com> | 2020-08-17 11:52:28 +0200 |
commit | 00d88f91c94751e7e6272b0d15e49582fd4f10da (patch) | |
tree | de62519146d63f7a3a5207e349fa2a1f64b4609e /plugins/base/src | |
parent | cc2c4f0033cfa2f1ebfa0b8aeb01b65823577c9a (diff) | |
download | dokka-00d88f91c94751e7e6272b0d15e49582fd4f10da.tar.gz dokka-00d88f91c94751e7e6272b0d15e49582fd4f10da.tar.bz2 dokka-00d88f91c94751e7e6272b0d15e49582fd4f10da.zip |
Implement shouldRenderSourceSetBubbles
Diffstat (limited to 'plugins/base/src')
-rw-r--r-- | plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt | 9 | ||||
-rw-r--r-- | plugins/base/src/main/kotlin/renderers/html/shouldRenderSourceSetBubbles.kt | 16 |
2 files changed, 20 insertions, 5 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 71a28345..ac2b1d02 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -34,9 +34,7 @@ open class HtmlRenderer( .filter { it in sourceSet.dependentSourceSets } }.toMap() - private val shouldShowSourceSetBubbles by lazy { - sourceSetDependencyMap.size > 1 - } + private var shouldRenderSourceSetBubbles: Boolean = false private val pageList = ConcurrentHashMap<String, Pair<String, String>>() @@ -109,7 +107,7 @@ open class HtmlRenderer( } private fun FlowContent.filterButtons(page: ContentPage) { - if (shouldShowSourceSetBubbles) { + if (shouldRenderSourceSetBubbles) { div(classes = "filter-section") { id = "filter-section" page.content.withDescendants().flatMap { it.sourceSets }.distinct().forEach { @@ -415,7 +413,7 @@ open class HtmlRenderer( } private fun FlowContent.createPlatformTagBubbles(sourceSets: List<ContentSourceSet>) { - if (shouldShowSourceSetBubbles) { + if (shouldRenderSourceSetBubbles) { div("platform-tags") { sourceSets.forEach { div("platform-tag") { @@ -650,6 +648,7 @@ open class HtmlRenderer( .joinToString(prefix = "[", separator = ",\n", postfix = "]") override fun render(root: RootPageNode) { + shouldRenderSourceSetBubbles = shouldRenderSourceSetBubbles(root) super.render(root) runBlocking(Dispatchers.Default) { launch { diff --git a/plugins/base/src/main/kotlin/renderers/html/shouldRenderSourceSetBubbles.kt b/plugins/base/src/main/kotlin/renderers/html/shouldRenderSourceSetBubbles.kt new file mode 100644 index 00000000..3de58870 --- /dev/null +++ b/plugins/base/src/main/kotlin/renderers/html/shouldRenderSourceSetBubbles.kt @@ -0,0 +1,16 @@ +package org.jetbrains.dokka.base.renderers.html + +import org.jetbrains.dokka.model.withDescendants +import org.jetbrains.dokka.pages.ContentPage +import org.jetbrains.dokka.pages.RootPageNode + +internal fun shouldRenderSourceSetBubbles(page: RootPageNode): Boolean { + return page.withDescendants() + .flatMap { pageNode -> + if (pageNode is ContentPage) pageNode.content.withDescendants() + else emptySequence() + } + .flatMap { contentNode -> contentNode.sourceSets } + .distinct() + .count() > 1 +} |