From 4c0af882d32dc4be40b67892b184566fac99635d Mon Sep 17 00:00:00 2001 From: IgnatBeresnev Date: Mon, 8 Aug 2022 15:27:53 +0200 Subject: [PATCH 1/3] Do not render platform tabs for common-only content --- core/api/core.api | 9 ++++++--- core/src/main/kotlin/model/DisplaySourceSet.kt | 6 ++++-- .../src/main/kotlin/renderers/html/HtmlRenderer.kt | 12 ++++++++++-- .../base/src/main/resources/dokka/styles/style.css | 4 ++-- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/core/api/core.api b/core/api/core.api index 0487146d76..9b6339c7d3 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -1391,7 +1391,8 @@ 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 (Lorg/jetbrains/dokka/DokkaConfiguration$DokkaSourceSet;)V - public fun (Lorg/jetbrains/dokka/model/CompositeSourceSetID;Ljava/lang/String;Lorg/jetbrains/dokka/Platform;)V + public fun (Lorg/jetbrains/dokka/model/CompositeSourceSetID;Ljava/lang/String;Lorg/jetbrains/dokka/Platform;Ljava/util/Set;)V + public synthetic fun (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 @@ -1399,13 +1400,15 @@ public final class org/jetbrains/dokka/model/DisplaySourceSet : org/jetbrains/do 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 diff --git a/core/src/main/kotlin/model/DisplaySourceSet.kt b/core/src/main/kotlin/model/DisplaySourceSet.kt index 85904db69f..f5a5a0aa5e 100644 --- a/core/src/main/kotlin/model/DisplaySourceSet.kt +++ b/core/src/main/kotlin/model/DisplaySourceSet.kt @@ -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 = emptySet() ) : SelfRepresentingSingletonSet { constructor(sourceSet: DokkaSourceSet) : this( sourceSetIDs = CompositeSourceSetID(sourceSet.sourceSetID), name = sourceSet.displayName, - platform = sourceSet.analysisPlatform + platform = sourceSet.analysisPlatform, + dependentSourceSetIDs = sourceSet.dependentSourceSets ) } diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 53645f060b..ec950a818a 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,19 @@ open class HtmlRenderer( shouldHaveTabs: Boolean = shouldRenderSourceSetBubbles ) { val contents = contentsForSourceSetDependent(nodes, pageContext) + val isOnlyCommonContent = contents.singleOrNull()?.let { (sourceSet, _) -> + sourceSet.platform == Platform.common && sourceSet.name == "common" && 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 -> diff --git a/plugins/base/src/main/resources/dokka/styles/style.css b/plugins/base/src/main/resources/dokka/styles/style.css index 989b54b80a..8e379c7502 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; } From b98d4941b513ca74f8b0630610fb79d4a1799845 Mon Sep 17 00:00:00 2001 From: IgnatBeresnev Date: Mon, 8 Aug 2022 16:22:27 +0200 Subject: [PATCH 2/3] Handle case-sensitive common source set name --- plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index ec950a818a..98386c72f0 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -203,7 +203,9 @@ open class HtmlRenderer( ) { val contents = contentsForSourceSetDependent(nodes, pageContext) val isOnlyCommonContent = contents.singleOrNull()?.let { (sourceSet, _) -> - sourceSet.platform == Platform.common && sourceSet.name == "common" && sourceSet.dependentSourceSetIDs.isEmpty() + sourceSet.platform == Platform.common + && sourceSet.name.equals("common", ignoreCase = true) + && sourceSet.dependentSourceSetIDs.isEmpty() } ?: false // little point in rendering a single "common" tab - it can be From cba0e56a74a4d891fa925731abff3ec52c6a95dc Mon Sep 17 00:00:00 2001 From: IgnatBeresnev Date: Wed, 17 Aug 2022 16:59:33 +0200 Subject: [PATCH 3/3] Remove dependentSourceSetIDs property --- core/api/core.api | 9 +++------ core/src/main/kotlin/model/DisplaySourceSet.kt | 6 ++---- .../base/src/main/kotlin/renderers/html/HtmlRenderer.kt | 2 +- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/core/api/core.api b/core/api/core.api index 9b6339c7d3..0487146d76 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -1391,8 +1391,7 @@ 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 (Lorg/jetbrains/dokka/DokkaConfiguration$DokkaSourceSet;)V - public fun (Lorg/jetbrains/dokka/model/CompositeSourceSetID;Ljava/lang/String;Lorg/jetbrains/dokka/Platform;Ljava/util/Set;)V - public synthetic fun (Lorg/jetbrains/dokka/model/CompositeSourceSetID;Ljava/lang/String;Lorg/jetbrains/dokka/Platform;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Lorg/jetbrains/dokka/model/CompositeSourceSetID;Ljava/lang/String;Lorg/jetbrains/dokka/Platform;)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 @@ -1400,15 +1399,13 @@ public final class org/jetbrains/dokka/model/DisplaySourceSet : org/jetbrains/do 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;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 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 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 diff --git a/core/src/main/kotlin/model/DisplaySourceSet.kt b/core/src/main/kotlin/model/DisplaySourceSet.kt index f5a5a0aa5e..85904db69f 100644 --- a/core/src/main/kotlin/model/DisplaySourceSet.kt +++ b/core/src/main/kotlin/model/DisplaySourceSet.kt @@ -8,14 +8,12 @@ import org.jetbrains.dokka.utilities.SelfRepresentingSingletonSet data class DisplaySourceSet( val sourceSetIDs: CompositeSourceSetID, val name: String, - val platform: Platform, - val dependentSourceSetIDs: Set = emptySet() + val platform: Platform ) : SelfRepresentingSingletonSet { constructor(sourceSet: DokkaSourceSet) : this( sourceSetIDs = CompositeSourceSetID(sourceSet.sourceSetID), name = sourceSet.displayName, - platform = sourceSet.analysisPlatform, - dependentSourceSetIDs = sourceSet.dependentSourceSets + platform = sourceSet.analysisPlatform ) } diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 98386c72f0..fbc118642d 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -205,7 +205,7 @@ open class HtmlRenderer( val isOnlyCommonContent = contents.singleOrNull()?.let { (sourceSet, _) -> sourceSet.platform == Platform.common && sourceSet.name.equals("common", ignoreCase = true) - && sourceSet.dependentSourceSetIDs.isEmpty() + && sourceSet.sourceSetIDs.all.all { sourceSetDependencyMap[it]?.isEmpty() == true } } ?: false // little point in rendering a single "common" tab - it can be