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 2 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
9 changes: 6 additions & 3 deletions core/api/core.api
Expand Up @@ -1391,21 +1391,24 @@ public final class org/jetbrains/dokka/model/DefinitelyNonNullable : org/jetbrai

public final class org/jetbrains/dokka/model/DisplaySourceSet : org/jetbrains/dokka/utilities/SelfRepresentingSingletonSet {
public fun <init> (Lorg/jetbrains/dokka/DokkaConfiguration$DokkaSourceSet;)V
public fun <init> (Lorg/jetbrains/dokka/model/CompositeSourceSetID;Ljava/lang/String;Lorg/jetbrains/dokka/Platform;)V
public fun <init> (Lorg/jetbrains/dokka/model/CompositeSourceSetID;Ljava/lang/String;Lorg/jetbrains/dokka/Platform;Ljava/util/Set;)V
public synthetic fun <init> (Lorg/jetbrains/dokka/model/CompositeSourceSetID;Ljava/lang/String;Lorg/jetbrains/dokka/Platform;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun add (Ljava/lang/Object;)Z
public fun add (Lorg/jetbrains/dokka/model/DisplaySourceSet;)Z
public fun addAll (Ljava/util/Collection;)Z
public fun clear ()V
public final fun component1 ()Lorg/jetbrains/dokka/model/CompositeSourceSetID;
public final fun component2 ()Ljava/lang/String;
public final fun component3 ()Lorg/jetbrains/dokka/Platform;
public final fun component4 ()Ljava/util/Set;
public final fun contains (Ljava/lang/Object;)Z
public fun contains (Lorg/jetbrains/dokka/model/DisplaySourceSet;)Z
public synthetic fun contains (Lorg/jetbrains/dokka/utilities/SelfRepresentingSingletonSet;)Z
public fun containsAll (Ljava/util/Collection;)Z
public final fun copy (Lorg/jetbrains/dokka/model/CompositeSourceSetID;Ljava/lang/String;Lorg/jetbrains/dokka/Platform;)Lorg/jetbrains/dokka/model/DisplaySourceSet;
public static synthetic fun copy$default (Lorg/jetbrains/dokka/model/DisplaySourceSet;Lorg/jetbrains/dokka/model/CompositeSourceSetID;Ljava/lang/String;Lorg/jetbrains/dokka/Platform;ILjava/lang/Object;)Lorg/jetbrains/dokka/model/DisplaySourceSet;
public final fun copy (Lorg/jetbrains/dokka/model/CompositeSourceSetID;Ljava/lang/String;Lorg/jetbrains/dokka/Platform;Ljava/util/Set;)Lorg/jetbrains/dokka/model/DisplaySourceSet;
public static synthetic fun copy$default (Lorg/jetbrains/dokka/model/DisplaySourceSet;Lorg/jetbrains/dokka/model/CompositeSourceSetID;Ljava/lang/String;Lorg/jetbrains/dokka/Platform;Ljava/util/Set;ILjava/lang/Object;)Lorg/jetbrains/dokka/model/DisplaySourceSet;
public fun equals (Ljava/lang/Object;)Z
public final fun getDependentSourceSetIDs ()Ljava/util/Set;
public final fun getName ()Ljava/lang/String;
public final fun getPlatform ()Lorg/jetbrains/dokka/Platform;
public fun getSize ()I
Expand Down
6 changes: 4 additions & 2 deletions core/src/main/kotlin/model/DisplaySourceSet.kt
Expand Up @@ -8,12 +8,14 @@ import org.jetbrains.dokka.utilities.SelfRepresentingSingletonSet
data class DisplaySourceSet(
val sourceSetIDs: CompositeSourceSetID,
val name: String,
val platform: Platform
val platform: Platform,
val dependentSourceSetIDs: Set<DokkaSourceSetID> = emptySet()
IgnatBeresnev marked this conversation as resolved.
Show resolved Hide resolved
) : SelfRepresentingSingletonSet<DisplaySourceSet> {
constructor(sourceSet: DokkaSourceSet) : this(
sourceSetIDs = CompositeSourceSetID(sourceSet.sourceSetID),
name = sourceSet.displayName,
platform = sourceSet.analysisPlatform
platform = sourceSet.analysisPlatform,
dependentSourceSetIDs = sourceSet.dependentSourceSets
)
}

Expand Down
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.dependentSourceSetIDs.isEmpty()
} ?: 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