aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin
diff options
context:
space:
mode:
authorBłażej Kardyś <bkardys@virtuslab.com>2020-05-20 16:19:49 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-05-20 16:32:01 +0200
commitdfefa90b4aa7ca0622cf01d14f4fb5083b8b74eb (patch)
treefc18a2f99d7be8820b753b1718cb0ad1ef74855d /plugins/base/src/main/kotlin
parent13be83e525dd889ff127a41d776f6635799530a4 (diff)
downloaddokka-dfefa90b4aa7ca0622cf01d14f4fb5083b8b74eb.tar.gz
dokka-dfefa90b4aa7ca0622cf01d14f4fb5083b8b74eb.tar.bz2
dokka-dfefa90b4aa7ca0622cf01d14f4fb5083b8b74eb.zip
Adding tag bubbles to merged hints
Diffstat (limited to 'plugins/base/src/main/kotlin')
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt34
1 files changed, 22 insertions, 12 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index 85005bc0..c62c5d3c 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -52,6 +52,7 @@ open class HtmlRenderer(
nodes: Map<SourceSetData, Collection<ContentNode>>,
pageContext: ContentPage
) {
+ var mergedToOneSourceSet : SourceSetData? = null
div("platform-hinted") {
attributes["data-platform-hinted"] = "data-platform-hinted"
var counter = 0
@@ -94,11 +95,14 @@ open class HtmlRenderer(
}
}
}
+ } else if (nodes.size > 1) {
+ mergedToOneSourceSet = contents.first().first
}
contents.forEach {
consumer.onTagContentUnsafe { +it.second }
}
}
+ mergedToOneSourceSet?.let { createPlatformTagBubbles(listOf(it)) }
}
override fun FlowContent.buildDivergent(node: ContentDivergentGroup, pageContext: ContentPage) {
@@ -239,24 +243,30 @@ open class HtmlRenderer(
}
}
- private fun FlowContent.createPlatformTags(node: ContentNode, sourceSetRestriction: Set<SourceSetData>? = null) {
- node.takeIf { sourceSetRestriction == null || it.sourceSets.any { s -> s in sourceSetRestriction } }?.let {
- div("platform-tags") {
- node.sourceSets.filter { sourceSetRestriction == null || it in sourceSetRestriction }.forEach { data ->
- div("platform-tag") {
- when(data.platform.key){
- "common" -> classes = classes + "common-like"
- "native" -> classes = classes + "native-like"
- "jvm" -> classes = classes + "jvm-like"
- "js" -> classes = classes + "js-like"
- }
- text(data.sourceSetName)
+ private fun FlowContent.createPlatformTagBubbles(sourceSets: List<SourceSetData>) {
+ div("platform-tags") {
+ sourceSets.forEach {
+ div("platform-tag") {
+ when(it.platform.key){
+ "common" -> classes = classes + "common-like"
+ "native" -> classes = classes + "native-like"
+ "jvm" -> classes = classes + "jvm-like"
+ "js" -> classes = classes + "js-like"
}
+ text(it.sourceSetName)
}
}
}
}
+ private fun FlowContent.createPlatformTags(node: ContentNode, sourceSetRestriction: Set<SourceSetData>? = null) {
+ node.takeIf { sourceSetRestriction == null || it.sourceSets.any { s -> s in sourceSetRestriction } }?.let {
+ createPlatformTagBubbles( node.sourceSets.filter {
+ sourceSetRestriction == null || it in sourceSetRestriction
+ })
+ }
+ }
+
override fun FlowContent.buildTable(
node: ContentTable,
pageContext: ContentPage,