Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not render platform tabs for common-only content #2613

Merged
merged 3 commits into from Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 {
Comment on lines +956 to +957
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because there's no tabs, now content is rendered the same way as for single platform projects, and there's currently a visual problem - no padding between paragraphs. See this page for instance

This should solve it for both single and multi platform pages

padding: 8px;
}

Expand Down