aboutsummaryrefslogtreecommitdiff
path: root/plugins/base
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2022-08-17 16:27:51 +0200
committerGitHub <noreply@github.com>2022-08-17 16:27:51 +0200
commite9e95f6bdefa2ea4bd2cc1a79ed642ff57b25e48 (patch)
tree1325bf4191333282785ae200185b57dd0a2d6120 /plugins/base
parentad1d48070d621b1feb5a0e8ceab90ed9367ac18b (diff)
downloaddokka-e9e95f6bdefa2ea4bd2cc1a79ed642ff57b25e48.tar.gz
dokka-e9e95f6bdefa2ea4bd2cc1a79ed642ff57b25e48.tar.bz2
dokka-e9e95f6bdefa2ea4bd2cc1a79ed642ff57b25e48.zip
Do not render platform tabs for common-only content (#2613)
Diffstat (limited to 'plugins/base')
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt14
-rw-r--r--plugins/base/src/main/resources/dokka/styles/style.css4
2 files changed, 14 insertions, 4 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index 55afef80..945fff38 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -3,6 +3,7 @@ package org.jetbrains.dokka.base.renderers.html
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.*
import org.jetbrains.dokka.base.renderers.html.command.consumers.ImmediateResolutionTagConsumer
@@ -201,12 +202,21 @@ open class HtmlRenderer(
shouldHaveTabs: Boolean = shouldRenderSourceSetBubbles
) {
val contents = contentsForSourceSetDependent(nodes, pageContext)
+ val isOnlyCommonContent = contents.singleOrNull()?.let { (sourceSet, _) ->
+ sourceSet.platform == Platform.common
+ && sourceSet.name.equals("common", ignoreCase = true)
+ && sourceSet.sourceSetIDs.all.all { sourceSetDependencyMap[it]?.isEmpty() == true }
+ } ?: false
- val divStyles = "platform-hinted ${styles.joinToString()}" + if (shouldHaveTabs) " with-platform-tabs" else ""
+ // little point in rendering a single "common" tab - it can be
+ // assumed that code without any tabs is common by default
+ val renderTabs = shouldHaveTabs && !isOnlyCommonContent
+
+ val divStyles = "platform-hinted ${styles.joinToString()}" + if (renderTabs) " with-platform-tabs" else ""
div(divStyles) {
attributes["data-platform-hinted"] = "data-platform-hinted"
extra.extraHtmlAttributes().forEach { attributes[it.extraKey] = it.extraValue }
- if (shouldHaveTabs) {
+ if (renderTabs) {
div("platform-bookmarks-row") {
attributes["data-toggle-list"] = "data-toggle-list"
contents.forEachIndexed { index, pair ->
diff --git a/plugins/base/src/main/resources/dokka/styles/style.css b/plugins/base/src/main/resources/dokka/styles/style.css
index 989b54b8..8e379c75 100644
--- a/plugins/base/src/main/resources/dokka/styles/style.css
+++ b/plugins/base/src/main/resources/dokka/styles/style.css
@@ -953,8 +953,8 @@ td.content {
padding-bottom: 8px;
}
-.table-row .with-platform-tabs .sourceset-dependent-content .brief,
-.table-row .with-platform-tabs .sourceset-dependent-content .inline-comment {
+.table-row .platform-hinted .sourceset-dependent-content .brief,
+.table-row .platform-hinted .sourceset-dependent-content .inline-comment {
padding: 8px;
}