From c461b042819a79188420fbcd3899cbc8189cd3c6 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Thu, 16 Jul 2020 13:47:41 +0200 Subject: Fix bug with filtering buttons not being created --- plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'plugins/base/src/main/kotlin') diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 44ca5e20..f331acc8 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -12,6 +12,7 @@ import org.jetbrains.dokka.base.renderers.DefaultRenderer import org.jetbrains.dokka.base.renderers.TabSortingStrategy import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.properties.PropertyContainer +import org.jetbrains.dokka.model.withDescendants import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.plugin @@ -38,9 +39,9 @@ open class HtmlRenderer( private val tabSortingStrategy = context.plugin().querySingle { tabSortingStrategy } - private fun sortTabs(strategy: TabSortingStrategy, tabs: Collection) : List { + private fun sortTabs(strategy: TabSortingStrategy, tabs: Collection): List { val sorted = strategy.sort(tabs) - if(sorted.size != tabs.size) + if (sorted.size != tabs.size) context.logger.warn("Tab sorting strategy has changed number of tabs from ${tabs.size} to ${sorted.size}") return sorted; } @@ -93,7 +94,7 @@ open class HtmlRenderer( node.dci.kind == ContentKind.Symbol -> div("symbol $additionalClasses") { childrenCallback() } node.dci.kind == ContentKind.BriefComment -> div("brief $additionalClasses") { childrenCallback() } node.dci.kind == ContentKind.Cover -> div("cover $additionalClasses") { - filterButtons(node) + filterButtons(pageContext) childrenCallback() } node.hasStyle(TextStyle.Paragraph) -> p(additionalClasses) { childrenCallback() } @@ -102,11 +103,11 @@ open class HtmlRenderer( } } - private fun FlowContent.filterButtons(group: ContentGroup) { + private fun FlowContent.filterButtons(page: ContentPage) { if (isMultiplatform) { div(classes = "filter-section") { id = "filter-section" - group.sourceSets.forEach { + page.content.withDescendants().flatMap { it.sourceSets }.distinct().forEach { button(classes = "platform-tag platform-selector") { attributes["data-active"] = "" attributes["data-filter"] = it.sourceSetID.toString() -- cgit