diff options
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 +} |