diff options
author | Błażej Kardyś <bkardys@virtuslab.com> | 2020-05-19 19:02:58 +0200 |
---|---|---|
committer | Błażej Kardyś <bkardys@virtuslab.com> | 2020-05-20 13:31:00 +0200 |
commit | 6b85bb2ec2764a2c8b14717ef8e013a0f3c6e99f (patch) | |
tree | f29b4101c306d824f39787d817bd038fbf740779 /plugins/base/src/main | |
parent | ff450fedb3c8bdc318b55954bc37d93b30b9277c (diff) | |
download | dokka-6b85bb2ec2764a2c8b14717ef8e013a0f3c6e99f.tar.gz dokka-6b85bb2ec2764a2c8b14717ef8e013a0f3c6e99f.tar.bz2 dokka-6b85bb2ec2764a2c8b14717ef8e013a0f3c6e99f.zip |
Merging of platform dependent hints in sourceset tree
Diffstat (limited to 'plugins/base/src/main')
-rw-r--r-- | plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index dd293e54..64c03bc7 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -6,7 +6,6 @@ import kotlinx.html.stream.createHTML import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.renderers.DefaultRenderer import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.DFunction import org.jetbrains.dokka.model.SourceSetData import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext @@ -19,6 +18,12 @@ open class HtmlRenderer( context: DokkaContext ) : DefaultRenderer<FlowContent>(context) { + private val sourceSetDependencyMap = with(context.sourceSetCache) { + allSourceSets.map { sourceSet -> + sourceSet to allSourceSets.filter { sourceSet.dependentSourceSets.contains(it.sourceSetName ) } + }.toMap() + } + private val pageList = mutableListOf<String>() override val preprocessors = context.plugin<DokkaBase>().query { htmlPreprocessors } + @@ -49,16 +54,26 @@ open class HtmlRenderer( ) { div("platform-hinted") { attributes["data-platform-hinted"] = "data-platform-hinted" - val contents = nodes.toList().mapIndexed { index, (sourceSet, elements) -> - sourceSet to createHTML(prettyPrint = false).div(classes = "content") { - if (index == 0) attributes["data-active"] = "" - attributes["data-togglable"] = sourceSet.sourceSetName + var counter = 0 + val contents = nodes.toList().map { (sourceSet, elements) -> + sourceSet to createHTML(prettyPrint = false).div { elements.forEach { buildContentNode(it, pageContext, setOf(sourceSet)) } + }.stripDiv() + }.groupBy(Pair<SourceSetData, String>::second, Pair<SourceSetData, String>::first).entries.flatMap { (html, sourceSets) -> + sourceSets.filterNot { + sourceSetDependencyMap[it].orEmpty().any { dependency -> sourceSets.contains(dependency) } + }.map { + it to createHTML(prettyPrint = false).div(classes = "content") { + if (counter++ == 0) attributes["data-active"] = "" + attributes["data-togglable"] = it.sourceSetName + unsafe { + +html + } + } } } - if (contents.size != 1) { div("platform-bookmarks-row") { attributes["data-toggle-list"] = "data-toggle-list" |