From e9e95f6bdefa2ea4bd2cc1a79ed642ff57b25e48 Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Wed, 17 Aug 2022 16:27:51 +0200 Subject: Do not render platform tabs for common-only content (#2613) --- .../base/src/main/kotlin/renderers/html/HtmlRenderer.kt | 14 ++++++++++++-- plugins/base/src/main/resources/dokka/styles/style.css | 4 ++-- 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; } -- cgit