Skip to content

Commit

Permalink
Do not render platform tabs for common-only content (#2613)
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnatBeresnev committed Aug 17, 2022
1 parent ad1d480 commit e9e95f6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
14 changes: 12 additions & 2 deletions plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
Expand Up @@ -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
Expand Down Expand Up @@ -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 ->
Expand Down
4 changes: 2 additions & 2 deletions plugins/base/src/main/resources/dokka/styles/style.css
Expand Up @@ -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;
}

Expand Down

0 comments on commit e9e95f6

Please sign in to comment.