aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/renderers
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src/main/kotlin/renderers')
-rw-r--r--plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt21
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt58
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt4
3 files changed, 42 insertions, 41 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
index 925767ce..1340529c 100644
--- a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
@@ -3,6 +3,7 @@ package org.jetbrains.dokka.base.renderers
import kotlinx.coroutines.*
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.resolvers.local.LocationProvider
+import org.jetbrains.dokka.model.SourceSetData
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.plugability.plugin
@@ -26,7 +27,7 @@ abstract class DefaultRenderer<T>(
abstract fun T.buildList(
node: ContentList,
pageContext: ContentPage,
- platformRestriction: PlatformData? = null
+ platformRestriction: SourceSetData? = null
)
abstract fun T.buildNewLine()
@@ -34,7 +35,7 @@ abstract class DefaultRenderer<T>(
abstract fun T.buildTable(
node: ContentTable,
pageContext: ContentPage,
- platformRestriction: PlatformData? = null
+ platformRestriction: SourceSetData? = null
)
abstract fun T.buildText(textNode: ContentText)
@@ -49,7 +50,7 @@ abstract class DefaultRenderer<T>(
open fun T.buildGroup(
node: ContentGroup,
pageContext: ContentPage,
- platformRestriction: PlatformData? = null
+ platformRestriction: SourceSetData? = null
) =
wrapGroup(node, pageContext) { node.children.forEach { it.build(this, pageContext, platformRestriction) } }
@@ -59,7 +60,7 @@ abstract class DefaultRenderer<T>(
open fun T.buildLinkText(
nodes: List<ContentNode>,
pageContext: ContentPage,
- platformRestriction: PlatformData? = null
+ platformRestriction: SourceSetData? = null
) {
nodes.forEach { it.build(this, pageContext, platformRestriction) }
}
@@ -71,7 +72,7 @@ abstract class DefaultRenderer<T>(
open fun T.buildHeader(
node: ContentHeader,
pageContext: ContentPage,
- platformRestriction: PlatformData? = null
+ platformRestriction: SourceSetData? = null
) {
buildHeader(node.level) { node.children.forEach { it.build(this, pageContext, platformRestriction) } }
}
@@ -79,22 +80,22 @@ abstract class DefaultRenderer<T>(
open fun ContentNode.build(
builder: T,
pageContext: ContentPage,
- platformRestriction: PlatformData? = null
+ platformRestriction: SourceSetData? = null
) =
builder.buildContentNode(this, pageContext, platformRestriction)
open fun T.buildContentNode(
node: ContentNode,
pageContext: ContentPage,
- platformRestriction: PlatformData? = null
+ platformRestriction: SourceSetData? = null
) {
- if (platformRestriction == null || platformRestriction in node.platforms) {
+ if (platformRestriction == null || platformRestriction in node.sourceSets) {
when (node) {
is ContentText -> buildText(node)
is ContentHeader -> buildHeader(node, pageContext, platformRestriction)
is ContentCode -> buildCode(node.children, node.language, pageContext)
is ContentDRILink ->
- buildLink(locationProvider.resolve(node.address, node.platforms.toList(), pageContext)) {
+ buildLink(locationProvider.resolve(node.address, node.sourceSets.toList(), pageContext)) {
buildLinkText(node.children, pageContext, platformRestriction)
}
is ContentResolvedLink -> buildLink(node.address) {
@@ -154,4 +155,4 @@ abstract class DefaultRenderer<T>(
}
}
-fun ContentPage.platforms() = this.content.platforms.toList() \ No newline at end of file
+fun ContentPage.platforms() = this.content.sourceSets.toList() \ 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 c061cabf..caabcda7 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -7,6 +7,7 @@ import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.renderers.DefaultRenderer
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.DFunction
+import org.jetbrains.dokka.model.SourceSetData
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.plugability.plugin
@@ -42,10 +43,10 @@ open class HtmlRenderer(
override fun FlowContent.buildPlatformDependent(content: PlatformHintedContent, pageContext: ContentPage) {
div("platform-hinted") {
attributes["data-platform-hinted"] = "data-platform-hinted"
- val contents = content.platforms.mapIndexed { index, platform ->
+ val contents = content.sourceSets.mapIndexed { index, platform ->
platform to createHTML(prettyPrint = false).div(classes = "content") {
if (index == 0) attributes["data-active"] = ""
- attributes["data-togglable"] = platform.targets.joinToString("-")
+ attributes["data-togglable"] = platform.sourceSetName
buildContentNode(content.inner, pageContext, platform)
}
}
@@ -56,8 +57,8 @@ open class HtmlRenderer(
contents.forEachIndexed { index, pair ->
button(classes = "platform-bookmark") {
if (index == 0) attributes["data-active"] = ""
- attributes["data-toggle"] = pair.first.targets.joinToString("-")
- text(pair.first.targets.joinToString(", "));
+ attributes["data-toggle"] = pair.first.sourceSetName
+ text(pair.first.sourceSetName)
}
}
}
@@ -71,27 +72,27 @@ open class HtmlRenderer(
override fun FlowContent.buildList(
node: ContentList,
pageContext: ContentPage,
- platformRestriction: PlatformData?
- ) = if (node.ordered) ol { buildListItems(node.children, pageContext, platformRestriction) }
- else ul { buildListItems(node.children, pageContext, platformRestriction) }
+ sourceSetRestriction: SourceSetData?
+ ) = if (node.ordered) ol { buildListItems(node.children, pageContext, sourceSetRestriction) }
+ else ul { buildListItems(node.children, pageContext, sourceSetRestriction) }
open fun OL.buildListItems(
items: List<ContentNode>,
pageContext: ContentPage,
- platformRestriction: PlatformData? = null
+ sourceSetRestriction: SourceSetData? = null
) {
items.forEach {
if (it is ContentList)
buildList(it, pageContext)
else
- li { it.build(this, pageContext, platformRestriction) }
+ li { it.build(this, pageContext, sourceSetRestriction) }
}
}
open fun UL.buildListItems(
items: List<ContentNode>,
pageContext: ContentPage,
- platformRestriction: PlatformData? = null
+ sourceSetRestriction: SourceSetData? = null
) {
items.forEach {
if (it is ContentList)
@@ -118,64 +119,63 @@ open class HtmlRenderer(
private fun FlowContent.buildRow(
node: ContentGroup,
pageContext: ContentPage,
- platformRestriction: PlatformData?
+ sourceSetRestriction: SourceSetData?
) {
node.children
.filter {
- platformRestriction == null || platformRestriction in it.platforms
+ sourceSetRestriction == null || sourceSetRestriction in it.sourceSets
}
.takeIf { it.isNotEmpty() }
?.let {
div(classes = "table-row") {
it.filter { it.dci.kind != ContentKind.Symbol }.takeIf { it.isNotEmpty() }?.let {
div("main-subrow ${node.style.joinToString { it.toString().decapitalize() }}") {
- it.filter { platformRestriction == null || platformRestriction in it.platforms }
+ it.filter { sourceSetRestriction == null || sourceSetRestriction in it.sourceSets }
.forEach {
when(it.dci.kind){
- ContentKind.PlatformDependantHint -> {
+ ContentKind.SourceSetDependantHint -> {
div("platform-dependant-row keyValue"){
div()
div("title"){
- it.build(this, pageContext, platformRestriction)
+ it.build(this, pageContext, sourceSetRestriction)
}
}
}
ContentKind.Main -> {
div("title-row"){
- it.build(this, pageContext, platformRestriction)
+ it.build(this, pageContext, sourceSetRestriction)
div()
- if (ContentKind.shouldBePlatformTagged(node.dci.kind) && node.platforms.size == 1) {
+ if (ContentKind.shouldBePlatformTagged(node.dci.kind) && node.sourceSets.size == 1) {
createPlatformTags(node)
} else {
div()
}
}
}
- else -> div { it.build(this, pageContext, platformRestriction) }
+ else -> div { it.build(this, pageContext, sourceSetRestriction) }
}
}
}
}
it.filter { it.dci.kind == ContentKind.Symbol }.takeIf { it.isNotEmpty() }?.let {
div("signature-subrow") {
- div("signatures"){
+ div("signatures") {
it.forEach {
- it.build(this, pageContext, platformRestriction)
+ it.build(this, pageContext, sourceSetRestriction)
}
}
}
}
}
- }
+ }
}
- private fun FlowContent.createPlatformTags( node: ContentNode ) {
+ private fun FlowContent.createPlatformTags(node: ContentNode) {
div("platform-tags") {
- node.platforms.forEach {
+ node.sourceSets.forEach {
div("platform-tag") {
- val targets = it.targets.joinToString(", ")
- if( targets.equals("common", ignoreCase = true) ) classes = classes + "common"
- text(it.targets.joinToString(", "))
+ if (it.sourceSetName.equals("common", ignoreCase = true)) classes = classes + "common"
+ text(it.sourceSetName)
}
}
}
@@ -184,11 +184,11 @@ open class HtmlRenderer(
override fun FlowContent.buildTable(
node: ContentTable,
pageContext: ContentPage,
- platformRestriction: PlatformData?
+ sourceSetRestriction: SourceSetData?
) {
div(classes = "table") {
node.children.forEach {
- buildRow(it, pageContext, platformRestriction)
+ buildRow(it, pageContext, sourceSetRestriction)
}
}
}
@@ -221,7 +221,7 @@ open class HtmlRenderer(
fun FlowContent.buildLink(
to: DRI,
- platforms: List<PlatformData>,
+ platforms: List<SourceSetData>,
from: PageNode? = null,
block: FlowContent.() -> Unit
) = buildLink(locationProvider.resolve(to, platforms, from), block)
diff --git a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt
index 4b90cc8a..4048c11e 100644
--- a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt
@@ -3,8 +3,8 @@ package org.jetbrains.dokka.base.renderers.html
import kotlinx.html.*
import kotlinx.html.stream.createHTML
import org.jetbrains.dokka.links.DRI
+import org.jetbrains.dokka.model.SourceSetData
import org.jetbrains.dokka.pages.PageNode
-import org.jetbrains.dokka.pages.PlatformData
import org.jetbrains.dokka.pages.RendererSpecificPage
import org.jetbrains.dokka.pages.RenderingStrategy
@@ -41,7 +41,7 @@ class NavigationPage(val root: NavigationNode) : RendererSpecificPage {
class NavigationNode(
val name: String,
val dri: DRI,
- val platforms: List<PlatformData>,
+ val platforms: List<SourceSetData>,
val children: List<NavigationNode>
)