diff options
Diffstat (limited to 'plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt')
-rw-r--r-- | plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt index 3758b8d3..15d2473f 100644 --- a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt +++ b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt @@ -3,6 +3,7 @@ package org.jetbrains.dokka.base.renderers.html import kotlinx.html.* import kotlinx.html.stream.createHTML import org.jetbrains.dokka.base.renderers.pageId +import org.jetbrains.dokka.base.templating.AddToNavigationCommand import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.DisplaySourceSet import org.jetbrains.dokka.model.WithChildren @@ -10,7 +11,7 @@ import org.jetbrains.dokka.pages.PageNode import org.jetbrains.dokka.pages.RendererSpecificPage import org.jetbrains.dokka.pages.RenderingStrategy -class NavigationPage(val root: NavigationNode) : RendererSpecificPage { +class NavigationPage(val root: NavigationNode, val moduleName: String) : RendererSpecificPage { override val name = "navigation" override val children = emptyList<PageNode>() @@ -18,14 +19,20 @@ class NavigationPage(val root: NavigationNode) : RendererSpecificPage { override fun modified(name: String, children: List<PageNode>) = this override val strategy = RenderingStrategy<HtmlRenderer> { - createHTML().visit(root, "nav-submenu", this) + createHTML().visit(root, this) + } + + private fun <R> TagConsumer<R>.visit(node: NavigationNode, renderer: HtmlRenderer): R = with(renderer) { + templateCommand(AddToNavigationCommand(moduleName)) { + visit(node,"${moduleName}-nav-submenu", renderer) + } } private fun <R> TagConsumer<R>.visit(node: NavigationNode, navId: String, renderer: HtmlRenderer): R = with(renderer) { div("sideMenuPart") { id = navId - attributes["pageId"] = node.pageId + attributes["pageId"] = "${moduleName}::${node.pageId}" div("overview") { buildLink(node.dri, node.sourceSets.toList()) { buildBreakableText(node.name) } if (node.children.isNotEmpty()) { @@ -47,7 +54,7 @@ data class NavigationNode( override val children: List<NavigationNode> ): WithChildren<NavigationNode> -fun NavigationPage.transform(block: (NavigationNode) -> NavigationNode) = NavigationPage(root.transform(block)) +fun NavigationPage.transform(block: (NavigationNode) -> NavigationNode) = NavigationPage(root.transform(block), moduleName) fun NavigationNode.transform(block: (NavigationNode) -> NavigationNode) = run(block).let { NavigationNode(it.name, it.dri, it.sourceSets, it.children.map(block)) } |