diff options
author | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-05-20 14:52:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-20 14:52:05 +0200 |
commit | ec9f4b3386ef979196e00334172051ece9a95acf (patch) | |
tree | f29b4101c306d824f39787d817bd038fbf740779 /plugins | |
parent | ff450fedb3c8bdc318b55954bc37d93b30b9277c (diff) | |
parent | 6b85bb2ec2764a2c8b14717ef8e013a0f3c6e99f (diff) | |
download | dokka-ec9f4b3386ef979196e00334172051ece9a95acf.tar.gz dokka-ec9f4b3386ef979196e00334172051ece9a95acf.tar.bz2 dokka-ec9f4b3386ef979196e00334172051ece9a95acf.zip |
Merge pull request #867 from Kotlin/f/merging-source-set-hints
Merging of platform dependent hints in sourceset tree
Diffstat (limited to 'plugins')
-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" |