diff options
author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2023-02-10 17:24:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-10 17:24:47 +0100 |
commit | f515abc3118143f1cac62616c02970b2926427a2 (patch) | |
tree | fc9db8963f928e4b35a7c27649fc52482d02342b /plugins/base/src/main/kotlin/renderers | |
parent | e2351ebcb15a745551fef47c707f0e4e65a707cd (diff) | |
download | dokka-f515abc3118143f1cac62616c02970b2926427a2.tar.gz dokka-f515abc3118143f1cac62616c02970b2926427a2.tar.bz2 dokka-f515abc3118143f1cac62616c02970b2926427a2.zip |
Display source set / platform indicators at all times (#2848)
Fixes #2847
Diffstat (limited to 'plugins/base/src/main/kotlin/renderers')
4 files changed, 16 insertions, 21 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 73fd07e0..b4d98b58 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -41,7 +41,7 @@ open class HtmlRenderer( setupSharedModel(templateModelMerger.invoke(templateModelFactories) { buildSharedModel() }) } - private var shouldRenderSourceSetBubbles: Boolean = false + private var shouldRenderSourceSetTabs: Boolean = false override val preprocessors = context.plugin<DokkaBase>().query { htmlPreprocessors } @@ -175,7 +175,7 @@ open class HtmlRenderer( pageContext: ContentPage, extra: PropertyContainer<ContentNode> = PropertyContainer.empty(), styles: Set<Style> = emptySet(), - shouldHaveTabs: Boolean = shouldRenderSourceSetBubbles + shouldHaveTabs: Boolean = shouldRenderSourceSetTabs ) { val contents = contentsForSourceSetDependent(nodes, pageContext) val isOnlyCommonContent = contents.singleOrNull()?.let { (sourceSet, _) -> @@ -500,19 +500,17 @@ open class HtmlRenderer( } private fun FlowContent.createPlatformTagBubbles(sourceSets: List<DisplaySourceSet>, cssClasses: String = "") { - if (shouldRenderSourceSetBubbles) { - div("platform-tags $cssClasses") { - sourceSets.sortedBy { it.name }.forEach { - div("platform-tag") { - when (it.platform.key) { - "common" -> classes = classes + "common-like" - "native" -> classes = classes + "native-like" - "jvm" -> classes = classes + "jvm-like" - "js" -> classes = classes + "js-like" - "wasm" -> classes = classes + "wasm-like" - } - text(it.name) + div("platform-tags $cssClasses") { + sourceSets.sortedBy { it.name }.forEach { + div("platform-tag") { + when (it.platform.key) { + "common" -> classes = classes + "common-like" + "native" -> classes = classes + "native-like" + "jvm" -> classes = classes + "jvm-like" + "js" -> classes = classes + "js-like" + "wasm" -> classes = classes + "wasm-like" } + text(it.name) } } } @@ -779,7 +777,7 @@ open class HtmlRenderer( } override fun render(root: RootPageNode) { - shouldRenderSourceSetBubbles = shouldRenderSourceSetBubbles(root) + shouldRenderSourceSetTabs = shouldRenderSourceSetTabs(root) super.render(root) } @@ -805,7 +803,6 @@ open class HtmlRenderer( page, resources, locationProvider, - shouldRenderSourceSetBubbles, generatedContent ) } diff --git a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelFactory.kt b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelFactory.kt index 6c746b37..3437271a 100644 --- a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelFactory.kt +++ b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/DefaultTemplateModelFactory.kt @@ -40,7 +40,6 @@ class DefaultTemplateModelFactory(val context: DokkaContext) : TemplateModelFact page: PageNode, resources: List<String>, locationProvider: LocationProvider, - shouldRenderSourceSetBubbles: Boolean, content: String ): TemplateMap { val path = locationProvider.resolve(page) @@ -66,7 +65,7 @@ class DefaultTemplateModelFactory(val context: DokkaContext) : TemplateModelFact } mapper["template_cmd"] = TemplateDirective(context.configuration, pathToRoot) - if (shouldRenderSourceSetBubbles && page is ContentPage) { + if (page is ContentPage) { val sourceSets = page.content.withDescendants() .flatMap { it.sourceSets } .distinct() diff --git a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/TemplateModelFactory.kt b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/TemplateModelFactory.kt index ceecf201..0d4c957e 100644 --- a/plugins/base/src/main/kotlin/renderers/html/innerTemplating/TemplateModelFactory.kt +++ b/plugins/base/src/main/kotlin/renderers/html/innerTemplating/TemplateModelFactory.kt @@ -8,9 +8,8 @@ interface TemplateModelFactory { page: PageNode, resources: List<String>, locationProvider: LocationProvider, - shouldRenderSourceSetBubbles: Boolean, content: String ): TemplateMap fun buildSharedModel(): TemplateMap -}
\ No newline at end of file +} diff --git a/plugins/base/src/main/kotlin/renderers/html/shouldRenderSourceSetBubbles.kt b/plugins/base/src/main/kotlin/renderers/html/shouldRenderSourceSetBubbles.kt index 3de58870..ce9dd1b7 100644 --- a/plugins/base/src/main/kotlin/renderers/html/shouldRenderSourceSetBubbles.kt +++ b/plugins/base/src/main/kotlin/renderers/html/shouldRenderSourceSetBubbles.kt @@ -4,7 +4,7 @@ import org.jetbrains.dokka.model.withDescendants import org.jetbrains.dokka.pages.ContentPage import org.jetbrains.dokka.pages.RootPageNode -internal fun shouldRenderSourceSetBubbles(page: RootPageNode): Boolean { +internal fun shouldRenderSourceSetTabs(page: RootPageNode): Boolean { return page.withDescendants() .flatMap { pageNode -> if (pageNode is ContentPage) pageNode.content.withDescendants() |