aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/renderers
diff options
context:
space:
mode:
authorKamil Doległo <kamilok1965@interia.pl>2020-06-19 14:08:49 +0200
committerPaweł Marks <pmarks@virtuslab.com>2020-06-25 20:23:58 +0200
commit8cb6efc97f8fa321381c95cc5f85a3ce7bc13c3f (patch)
treefe4e24d9f352199e551bd34ba330c0d2c0acf7af /plugins/base/src/main/kotlin/renderers
parent08f40e2a13006882e8f8425f111b8527e7bbcb0f (diff)
downloaddokka-8cb6efc97f8fa321381c95cc5f85a3ce7bc13c3f.tar.gz
dokka-8cb6efc97f8fa321381c95cc5f85a3ce7bc13c3f.tar.bz2
dokka-8cb6efc97f8fa321381c95cc5f85a3ce7bc13c3f.zip
Remove SourceSetDataCache, rename PassConfiguration to DokkaSourceSet and use it instead of SourceSetData
Diffstat (limited to 'plugins/base/src/main/kotlin/renderers')
-rw-r--r--plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt28
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt60
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt8
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt2
4 files changed, 51 insertions, 47 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
index 141a18e6..f4d547e3 100644
--- a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
@@ -1,10 +1,12 @@
package org.jetbrains.dokka.base.renderers
-import kotlinx.coroutines.*
-import kotlinx.html.FlowContent
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.coroutineScope
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.runBlocking
+import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet
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
@@ -28,7 +30,7 @@ abstract class DefaultRenderer<T>(
abstract fun T.buildList(
node: ContentList,
pageContext: ContentPage,
- sourceSetRestriction: Set<SourceSetData>? = null
+ sourceSetRestriction: Set<DokkaSourceSet>? = null
)
abstract fun T.buildNewLine()
@@ -36,7 +38,7 @@ abstract class DefaultRenderer<T>(
abstract fun T.buildTable(
node: ContentTable,
pageContext: ContentPage,
- sourceSetRestriction: Set<SourceSetData>? = null
+ sourceSetRestriction: Set<DokkaSourceSet>? = null
)
abstract fun T.buildText(textNode: ContentText)
@@ -48,18 +50,18 @@ abstract class DefaultRenderer<T>(
open fun T.buildPlatformDependent(
content: PlatformHintedContent,
pageContext: ContentPage,
- sourceSetRestriction: Set<SourceSetData>?
+ sourceSetRestriction: Set<DokkaSourceSet>?
) = buildContentNode(content.inner, pageContext)
open fun T.buildGroup(
node: ContentGroup,
pageContext: ContentPage,
- sourceSetRestriction: Set<SourceSetData>? = null
+ sourceSetRestriction: Set<DokkaSourceSet>? = null
) =
wrapGroup(node, pageContext) { node.children.forEach { it.build(this, pageContext, sourceSetRestriction) } }
open fun T.buildDivergent(node: ContentDivergentGroup, pageContext: ContentPage) =
- node.children.forEach { it.build(this, pageContext) }
+ node.children.forEach { it.build(this, pageContext) }
open fun T.wrapGroup(node: ContentGroup, pageContext: ContentPage, childrenCallback: T.() -> Unit) =
childrenCallback()
@@ -67,7 +69,7 @@ abstract class DefaultRenderer<T>(
open fun T.buildLinkText(
nodes: List<ContentNode>,
pageContext: ContentPage,
- sourceSetRestriction: Set<SourceSetData>? = null
+ sourceSetRestriction: Set<DokkaSourceSet>? = null
) {
nodes.forEach { it.build(this, pageContext, sourceSetRestriction) }
}
@@ -79,7 +81,7 @@ abstract class DefaultRenderer<T>(
open fun T.buildHeader(
node: ContentHeader,
pageContext: ContentPage,
- sourceSetRestriction: Set<SourceSetData>? = null
+ sourceSetRestriction: Set<DokkaSourceSet>? = null
) {
buildHeader(node.level, node) { node.children.forEach { it.build(this, pageContext, sourceSetRestriction) } }
}
@@ -87,16 +89,16 @@ abstract class DefaultRenderer<T>(
open fun ContentNode.build(
builder: T,
pageContext: ContentPage,
- sourceSetRestriction: Set<SourceSetData>? = null
+ sourceSetRestriction: Set<DokkaSourceSet>? = null
) =
builder.buildContentNode(this, pageContext, sourceSetRestriction)
open fun T.buildContentNode(
node: ContentNode,
pageContext: ContentPage,
- sourceSetRestriction: Set<SourceSetData>? = null
+ sourceSetRestriction: Set<DokkaSourceSet>? = null
) {
- if (sourceSetRestriction == null || node.sourceSets.any { it in sourceSetRestriction } ) {
+ if (sourceSetRestriction == null || node.sourceSets.any { it in sourceSetRestriction }) {
when (node) {
is ContentText -> buildText(node)
is ContentHeader -> buildHeader(node, pageContext, sourceSetRestriction)
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index 43722888..ee6f1e1f 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -1,13 +1,15 @@
package org.jetbrains.dokka.base.renderers.html
-import kotlinx.coroutines.*
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.runBlocking
import kotlinx.html.*
import kotlinx.html.stream.createHTML
+import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet
import org.jetbrains.dokka.Platform
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.renderers.DefaultRenderer
import org.jetbrains.dokka.links.DRI
-import org.jetbrains.dokka.model.*
import org.jetbrains.dokka.model.properties.PropertyContainer
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.plugability.DokkaContext
@@ -20,11 +22,10 @@ open class HtmlRenderer(
context: DokkaContext
) : DefaultRenderer<FlowContent>(context) {
- private val sourceSetDependencyMap = with(context.sourceSetCache) {
- allSourceSets.map { sourceSet ->
- sourceSet to allSourceSets.filter { sourceSet.dependentSourceSets.contains(it.sourceSetID) }
- }.toMap()
- }
+ private val sourceSetDependencyMap = context.configuration.sourceSets.map { sourceSet ->
+ sourceSet to context.configuration.sourceSets.filter { sourceSet.dependentSourceSets.contains(it.sourceSetID) }
+ }.toMap()
+
private val pageList = mutableMapOf<String, Pair<String, String>>()
@@ -94,7 +95,7 @@ open class HtmlRenderer(
button(classes = "platform-tag platform-selector") {
attributes["data-active"] = ""
attributes["data-filter"] = it.sourceSetID
- when (it.platform.key) {
+ when (it.analysisPlatform.key) {
"common" -> classes = classes + "common-like"
"native" -> classes = classes + "native-like"
"jvm" -> classes = classes + "jvm-like"
@@ -138,7 +139,7 @@ open class HtmlRenderer(
override fun FlowContent.buildPlatformDependent(
content: PlatformHintedContent,
pageContext: ContentPage,
- sourceSetRestriction: Set<SourceSetData>?
+ sourceSetRestriction: Set<DokkaSourceSet>?
) =
buildPlatformDependent(
content.sourceSets.filter {
@@ -150,7 +151,7 @@ open class HtmlRenderer(
)
private fun FlowContent.buildPlatformDependent(
- nodes: Map<SourceSetData, Collection<ContentNode>>,
+ nodes: Map<DokkaSourceSet, Collection<ContentNode>>,
pageContext: ContentPage,
extra: PropertyContainer<ContentNode> = PropertyContainer.empty(),
styles: Set<Style> = emptySet()
@@ -172,7 +173,7 @@ open class HtmlRenderer(
if (index == 0) attributes["data-active"] = ""
attributes["data-toggle"] = pair.first.sourceSetID
when (
- pair.first.platform.key
+ pair.first.analysisPlatform.key
) {
"common" -> classes = classes + "common-like"
"native" -> classes = classes + "native-like"
@@ -192,9 +193,9 @@ open class HtmlRenderer(
}
private fun contentsForSourceSetDependent(
- nodes: Map<SourceSetData, Collection<ContentNode>>,
+ nodes: Map<DokkaSourceSet, Collection<ContentNode>>,
pageContext: ContentPage,
- ): List<Pair<SourceSetData, String>> {
+ ): List<Pair<DokkaSourceSet, String>> {
var counter = 0
return nodes.toList().map { (sourceSet, elements) ->
sourceSet to createHTML(prettyPrint = false).div {
@@ -203,8 +204,8 @@ open class HtmlRenderer(
}
}.stripDiv()
}.groupBy(
- Pair<SourceSetData, String>::second,
- Pair<SourceSetData, String>::first
+ Pair<DokkaSourceSet, String>::second,
+ Pair<DokkaSourceSet, String>::first
).entries.flatMap { (html, sourceSets) ->
sourceSets.filterNot {
sourceSetDependencyMap[it].orEmpty().any { dependency -> sourceSets.contains(dependency) }
@@ -238,8 +239,8 @@ open class HtmlRenderer(
)
}
}.groupBy(
- Pair<Pair<ContentDivergentInstance, SourceSetData>, Pair<String, String>>::second,
- Pair<Pair<ContentDivergentInstance, SourceSetData>, Pair<String, String>>::first
+ Pair<Pair<ContentDivergentInstance, DokkaSourceSet>, Pair<String, String>>::second,
+ Pair<Pair<ContentDivergentInstance, DokkaSourceSet>, Pair<String, String>>::first
)
distinct.forEach {
@@ -293,14 +294,14 @@ open class HtmlRenderer(
override fun FlowContent.buildList(
node: ContentList,
pageContext: ContentPage,
- sourceSetRestriction: Set<SourceSetData>?
+ sourceSetRestriction: Set<DokkaSourceSet>?
) = 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,
- sourceSetRestriction: Set<SourceSetData>? = null
+ sourceSetRestriction: Set<DokkaSourceSet>? = null
) {
items.forEach {
if (it is ContentList)
@@ -313,7 +314,7 @@ open class HtmlRenderer(
open fun UL.buildListItems(
items: List<ContentNode>,
pageContext: ContentPage,
- sourceSetRestriction: Set<SourceSetData>? = null
+ sourceSetRestriction: Set<DokkaSourceSet>? = null
) {
items.forEach {
if (it is ContentList)
@@ -340,7 +341,7 @@ open class HtmlRenderer(
private fun FlowContent.buildRow(
node: ContentGroup,
pageContext: ContentPage,
- sourceSetRestriction: Set<SourceSetData>?,
+ sourceSetRestriction: Set<DokkaSourceSet>?,
style: Set<Style>
) {
node.children
@@ -393,11 +394,11 @@ open class HtmlRenderer(
}
}
- private fun FlowContent.createPlatformTagBubbles(sourceSets: List<SourceSetData>) {
+ private fun FlowContent.createPlatformTagBubbles(sourceSets: List<DokkaSourceSet>) {
div("platform-tags") {
sourceSets.forEach {
div("platform-tag") {
- when (it.platform.key) {
+ when (it.analysisPlatform.key) {
"common" -> classes = classes + "common-like"
"native" -> classes = classes + "native-like"
"jvm" -> classes = classes + "jvm-like"
@@ -409,7 +410,7 @@ open class HtmlRenderer(
}
}
- private fun FlowContent.createPlatformTags(node: ContentNode, sourceSetRestriction: Set<SourceSetData>? = null) {
+ private fun FlowContent.createPlatformTags(node: ContentNode, sourceSetRestriction: Set<DokkaSourceSet>? = null) {
node.takeIf { sourceSetRestriction == null || it.sourceSets.any { s -> s in sourceSetRestriction } }?.let {
createPlatformTagBubbles(node.sourceSets.filter {
sourceSetRestriction == null || it in sourceSetRestriction
@@ -420,7 +421,7 @@ open class HtmlRenderer(
override fun FlowContent.buildTable(
node: ContentTable,
pageContext: ContentPage,
- sourceSetRestriction: Set<SourceSetData>?
+ sourceSetRestriction: Set<DokkaSourceSet>?
) {
when (node.dci.kind) {
ContentKind.Comment -> buildDefaultTable(node, pageContext, sourceSetRestriction)
@@ -437,7 +438,7 @@ open class HtmlRenderer(
fun FlowContent.buildDefaultTable(
node: ContentTable,
pageContext: ContentPage,
- sourceSetRestriction: Set<SourceSetData>?
+ sourceSetRestriction: Set<DokkaSourceSet>?
) {
table {
thead {
@@ -522,7 +523,7 @@ open class HtmlRenderer(
fun FlowContent.buildLink(
to: DRI,
- platforms: List<SourceSetData>,
+ platforms: List<DokkaSourceSet>,
from: PageNode? = null,
block: FlowContent.() -> Unit
) = buildLink(locationProvider.resolve(to, platforms, from), block)
@@ -562,7 +563,7 @@ open class HtmlRenderer(
private fun getSymbolSignature(page: ContentPage) = page.content.dfs { it.dci.kind == ContentKind.Symbol }
private fun flattenToText(node: ContentNode): String {
- fun getContentTextNodes(node: ContentNode, sourceSetRestriction: SourceSetData): List<ContentText> =
+ fun getContentTextNodes(node: ContentNode, sourceSetRestriction: DokkaSourceSet): List<ContentText> =
when (node) {
is ContentText -> listOf(node)
is ContentComposite -> node.children
@@ -573,7 +574,8 @@ open class HtmlRenderer(
else -> emptyList()
}
- val sourceSetRestriction = node.sourceSets.find { it.platform == Platform.common } ?: node.sourceSets.first()
+ val sourceSetRestriction =
+ node.sourceSets.find { it.analysisPlatform == Platform.common } ?: node.sourceSets.first()
return getContentTextNodes(node, sourceSetRestriction).joinToString("") { it.text }
}
diff --git a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt
index 4048c11e..eb563dbd 100644
--- a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt
@@ -3,7 +3,7 @@ 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.DokkaConfiguration.DokkaSourceSet
import org.jetbrains.dokka.pages.PageNode
import org.jetbrains.dokka.pages.RendererSpecificPage
import org.jetbrains.dokka.pages.RenderingStrategy
@@ -25,7 +25,7 @@ class NavigationPage(val root: NavigationNode) : RendererSpecificPage {
id = navId
attributes["pageId"] = node.dri.toString()
div("overview") {
- buildLink(node.dri, node.platforms) { +node.name }
+ buildLink(node.dri, node.sourceSets) { +node.name }
if (node.children.isNotEmpty()) {
span("navButton") {
onClick = """document.getElementById("$navId").classList.toggle("hidden");"""
@@ -41,11 +41,11 @@ class NavigationPage(val root: NavigationNode) : RendererSpecificPage {
class NavigationNode(
val name: String,
val dri: DRI,
- val platforms: List<SourceSetData>,
+ val sourceSets: List<DokkaSourceSet>,
val children: List<NavigationNode>
)
fun NavigationPage.transform(block: (NavigationNode) -> NavigationNode) = NavigationPage(root.transform(block))
fun NavigationNode.transform(block: (NavigationNode) -> NavigationNode) =
- run(block).let { NavigationNode(it.name, it.dri, it.platforms, it.children.map(block)) }
+ run(block).let { NavigationNode(it.name, it.dri, it.sourceSets, it.children.map(block)) }
diff --git a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt
index cdb30555..af0525d7 100644
--- a/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/htmlPreprocessors.kt
@@ -86,7 +86,7 @@ object StyleAndScriptsAppender : PageTransformer {
class SourcesetDependencyAppender(val context: DokkaContext) : PageTransformer{
override fun invoke(input: RootPageNode): RootPageNode {
- val dependenciesMap = context.configuration.passesConfigurations.map {
+ val dependenciesMap = context.configuration.sourceSets.map {
it.sourceSetID to it.dependentSourceSets
}.toMap()
fun createDependenciesJson() : String = "sourceset_dependencies = '{${