diff options
Diffstat (limited to 'plugins/base/src/main')
6 files changed, 30 insertions, 10 deletions
diff --git a/plugins/base/src/main/kotlin/DokkaBase.kt b/plugins/base/src/main/kotlin/DokkaBase.kt index afda6f24..8289447c 100644 --- a/plugins/base/src/main/kotlin/DokkaBase.kt +++ b/plugins/base/src/main/kotlin/DokkaBase.kt @@ -209,4 +209,4 @@ class DokkaBase : DokkaPlugin() { val baseSearchbarDataInstaller by extending { htmlPreprocessors providing ::SearchbarDataInstaller order { after(sourceLinksTransformer) } } -} +}
\ No newline at end of file diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 661e1e58..16f60a83 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -706,7 +706,8 @@ open class HtmlRenderer( buildHtml(page, page.embeddedResources) { div("main-content") { id = "content" - attributes["pageIds"] = page.pageId + // TODO: Investigate possible problem + attributes["pageIds"] = "${context.configuration.moduleName}::${page.pageId}" content(this, page) } } 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)) } diff --git a/plugins/base/src/main/kotlin/renderers/html/Tags.kt b/plugins/base/src/main/kotlin/renderers/html/Tags.kt index 67eed686..3db49ebf 100644 --- a/plugins/base/src/main/kotlin/renderers/html/Tags.kt +++ b/plugins/base/src/main/kotlin/renderers/html/Tags.kt @@ -13,9 +13,19 @@ open class WBR(initialAttributes: Map<String, String>, consumer: TagConsumer<*>) HTMLTag("wbr", consumer, initialAttributes, namespace = null, inlineTag = true, emptyTag = false), HtmlBlockInlineTag -fun FlowOrPhrasingContent.templateCommand(data: Command, block: TemplateCommand.() -> Unit = {}):Unit = +fun FlowOrPhrasingContent.templateCommand(data: Command, block: TemplateCommand.() -> Unit = {}): Unit = TemplateCommand(attributesMapOf("data", toJsonString(data)), consumer).visit(block) +fun <T> TagConsumer<T>.templateCommand(data: Command, block: TemplateCommand.() -> Unit = {}): T = + TemplateCommand(attributesMapOf("data", toJsonString(data)), this).visitAndFinalize(this, block) + class TemplateCommand(initialAttributes: Map<String, String>, consumer: TagConsumer<*>) : - HTMLTag("dokka-template-command", consumer, initialAttributes, namespace = null, inlineTag = true, emptyTag = false), + HTMLTag( + "dokka-template-command", + consumer, + initialAttributes, + namespace = null, + inlineTag = true, + emptyTag = false + ), CommonAttributeGroupFacadeFlowInteractivePhrasingContent diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt index 45159fea..fbebec70 100644 --- a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt +++ b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt @@ -177,5 +177,4 @@ class SourcesetDependencyAppender(val context: DokkaContext) : PageTransformer { children = input.children + deps ).transformContentPagesTree { it.modified(embeddedResources = it.embeddedResources + name) } } -} - +}
\ No newline at end of file diff --git a/plugins/base/src/main/kotlin/templating/AddToNavigationCommand.kt b/plugins/base/src/main/kotlin/templating/AddToNavigationCommand.kt new file mode 100644 index 00000000..817501d7 --- /dev/null +++ b/plugins/base/src/main/kotlin/templating/AddToNavigationCommand.kt @@ -0,0 +1,3 @@ +package org.jetbrains.dokka.base.templating + +class AddToNavigationCommand(val moduleName: String) : Command |