From 1634c8a0184749ae9314adecf409851c35e93775 Mon Sep 17 00:00:00 2001 From: Marcin Aman Date: Thu, 20 Aug 2020 17:44:22 +0200 Subject: Make NavigationNode implement WithChildren --- plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt | 5 +++-- plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt | 5 ++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'plugins') diff --git a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt index f569ed12..24065e57 100644 --- a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt +++ b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt @@ -4,6 +4,7 @@ import kotlinx.html.* import kotlinx.html.stream.createHTML import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.DisplaySourceSet +import org.jetbrains.dokka.model.WithChildren import org.jetbrains.dokka.pages.PageNode import org.jetbrains.dokka.pages.RendererSpecificPage import org.jetbrains.dokka.pages.RenderingStrategy @@ -42,8 +43,8 @@ data class NavigationNode( val name: String, val dri: DRI, val sourceSets: Set, - val children: List -) + override val children: List +): WithChildren fun NavigationPage.transform(block: (NavigationNode) -> NavigationNode) = NavigationPage(root.transform(block)) diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt index 6e779931..f4c9a1f7 100644 --- a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt +++ b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt @@ -11,6 +11,7 @@ import org.jetbrains.dokka.base.renderers.sourceSets import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.DEnum import org.jetbrains.dokka.model.DEnumEntry +import org.jetbrains.dokka.model.withDescendants import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.pages.PageTransformer @@ -61,9 +62,7 @@ object NavigationPageInstaller : PageTransformer { name = "scripts/navigation-pane.json", children = emptyList(), strategy = RenderingStrategy.LocationResolvableWrite { resolver -> - val flattened = flattenNavigationNodes(listOf(nodes)) - val view = flattened.map { NavigationNodeView.from(it, resolver(it.dri, it.sourceSets)) } - mapper.writeValueAsString(view) + mapper.writeValueAsString(nodes.withDescendants().map { NavigationNodeView.from(it, resolver(it.dri, it.sourceSets)) }) }) return input.modified( -- cgit