aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/kotlin/model/Documentable.kt1
-rw-r--r--core/src/main/kotlin/pages/ContentNodes.kt45
-rw-r--r--core/src/main/kotlin/pages/ContentSourceSet.kt61
-rw-r--r--core/src/main/kotlin/pages/PageNodes.kt15
-rw-r--r--core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt3
-rw-r--r--core/src/main/kotlin/transformers/pages/PageTransformer.kt14
-rw-r--r--core/src/test/kotlin/model/CompositeSourceSetIDTest.kt58
-rw-r--r--core/src/test/kotlin/model/ContentSourceSetTest.kt61
-rw-r--r--plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt25
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt58
-rw-r--r--plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt4
-rw-r--r--plugins/base/src/main/kotlin/resolvers/local/BaseLocationProvider.kt9
-rw-r--r--plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt3
-rw-r--r--plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt4
-rw-r--r--plugins/base/src/main/kotlin/resolvers/local/MultimoduleLocationProvider.kt4
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt42
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt2
-rw-r--r--plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt2
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt2
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt28
-rw-r--r--plugins/gfm/src/main/kotlin/GfmPlugin.kt47
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt15
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationProvider.kt4
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocContentNodes.kt23
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/KorteJavadocRenderer.kt2
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/SearchScriptsCreator.kt57
26 files changed, 414 insertions, 175 deletions
diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt
index 3f91e3cb..33c29ea3 100644
--- a/core/src/main/kotlin/model/Documentable.kt
+++ b/core/src/main/kotlin/model/Documentable.kt
@@ -14,6 +14,7 @@ abstract class Documentable : WithChildren<Documentable> {
abstract val documentation: SourceSetDependent<DocumentationNode>
abstract val sourceSets: Set<DokkaSourceSet>
abstract val expectPresentInSet: DokkaSourceSet?
+ abstract override val children: List<Documentable>
override fun toString(): String =
"${javaClass.simpleName}($dri)"
diff --git a/core/src/main/kotlin/pages/ContentNodes.kt b/core/src/main/kotlin/pages/ContentNodes.kt
index 5129dfcf..b82c023f 100644
--- a/core/src/main/kotlin/pages/ContentNodes.kt
+++ b/core/src/main/kotlin/pages/ContentNodes.kt
@@ -1,6 +1,8 @@
package org.jetbrains.dokka.pages
import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet
+import org.jetbrains.dokka.DokkaSourceSetID
+import org.jetbrains.dokka.Platform
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.WithChildren
import org.jetbrains.dokka.model.properties.PropertyContainer
@@ -10,9 +12,10 @@ data class DCI(val dri: Set<DRI>, val kind: Kind) {
override fun toString() = "$dri[$kind]"
}
+
interface ContentNode : WithExtraProperties<ContentNode>, WithChildren<ContentNode> {
val dci: DCI
- val sourceSets: Set<DokkaSourceSet>
+ val sourceSets: Set<ContentSourceSet>
val style: Set<Style>
fun hasAnyContent(): Boolean
@@ -25,7 +28,7 @@ interface ContentNode : WithExtraProperties<ContentNode>, WithChildren<ContentNo
data class ContentText(
val text: String,
override val dci: DCI,
- override val sourceSets: Set<DokkaSourceSet>,
+ override val sourceSets: Set<ContentSourceSet>,
override val style: Set<Style> = emptySet(),
override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
) : ContentNode {
@@ -36,7 +39,7 @@ data class ContentText(
// TODO: Remove
data class ContentBreakLine(
- override val sourceSets: Set<DokkaSourceSet>,
+ override val sourceSets: Set<ContentSourceSet>,
override val dci: DCI = DCI(emptySet(), ContentKind.Empty),
override val style: Set<Style> = emptySet(),
override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
@@ -51,7 +54,7 @@ data class ContentHeader(
override val children: List<ContentNode>,
val level: Int,
override val dci: DCI,
- override val sourceSets: Set<DokkaSourceSet>,
+ override val sourceSets: Set<ContentSourceSet>,
override val style: Set<Style>,
override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
) : ContentComposite {
@@ -67,7 +70,7 @@ data class ContentCodeBlock(
override val children: List<ContentNode>,
val language: String,
override val dci: DCI,
- override val sourceSets: Set<DokkaSourceSet>,
+ override val sourceSets: Set<ContentSourceSet>,
override val style: Set<Style>,
override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
) : ContentCode {
@@ -78,7 +81,7 @@ data class ContentCodeInline(
override val children: List<ContentNode>,
val language: String,
override val dci: DCI,
- override val sourceSets: Set<DokkaSourceSet>,
+ override val sourceSets: Set<ContentSourceSet>,
override val style: Set<Style>,
override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
) : ContentCode {
@@ -93,7 +96,7 @@ data class ContentDRILink(
override val children: List<ContentNode>,
val address: DRI,
override val dci: DCI,
- override val sourceSets: Set<DokkaSourceSet>,
+ override val sourceSets: Set<ContentSourceSet>,
override val style: Set<Style> = emptySet(),
override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
) : ContentLink {
@@ -105,7 +108,7 @@ data class ContentResolvedLink(
override val children: List<ContentNode>,
val address: String,
override val dci: DCI,
- override val sourceSets: Set<DokkaSourceSet>,
+ override val sourceSets: Set<ContentSourceSet>,
override val style: Set<Style> = emptySet(),
override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
) : ContentLink {
@@ -119,7 +122,7 @@ data class ContentEmbeddedResource(
val address: String,
val altText: String?,
override val dci: DCI,
- override val sourceSets: Set<DokkaSourceSet>,
+ override val sourceSets: Set<ContentSourceSet>,
override val style: Set<Style> = emptySet(),
override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
) : ContentLink {
@@ -139,7 +142,7 @@ data class ContentTable(
val header: List<ContentGroup>,
override val children: List<ContentGroup>,
override val dci: DCI,
- override val sourceSets: Set<DokkaSourceSet>,
+ override val sourceSets: Set<ContentSourceSet>,
override val style: Set<Style>,
override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
) : ContentComposite {
@@ -151,7 +154,7 @@ data class ContentList(
override val children: List<ContentNode>,
val ordered: Boolean,
override val dci: DCI,
- override val sourceSets: Set<DokkaSourceSet>,
+ override val sourceSets: Set<ContentSourceSet>,
override val style: Set<Style>,
override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
) : ContentComposite {
@@ -162,7 +165,7 @@ data class ContentList(
data class ContentGroup(
override val children: List<ContentNode>,
override val dci: DCI,
- override val sourceSets: Set<DokkaSourceSet>,
+ override val sourceSets: Set<ContentSourceSet>,
override val style: Set<Style>,
override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
) : ContentComposite {
@@ -182,7 +185,7 @@ data class ContentDivergentGroup(
) : ContentComposite {
data class GroupID(val name: String)
- override val sourceSets: Set<DokkaSourceSet>
+ override val sourceSets: Set<ContentSourceSet>
get() = children.flatMap { it.sourceSets }.distinct().toSet()
override fun withNewExtras(newExtras: PropertyContainer<ContentNode>): ContentDivergentGroup =
@@ -195,7 +198,7 @@ data class ContentDivergentInstance(
val divergent: ContentNode,
val after: ContentNode?,
override val dci: DCI,
- override val sourceSets: Set<DokkaSourceSet>,
+ override val sourceSets: Set<ContentSourceSet>,
override val style: Set<Style>,
override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
) : ContentComposite {
@@ -208,7 +211,7 @@ data class ContentDivergentInstance(
data class PlatformHintedContent(
val inner: ContentNode,
- override val sourceSets: Set<DokkaSourceSet>
+ override val sourceSets: Set<ContentSourceSet>
) : ContentComposite {
override val children = listOf(inner)
@@ -235,7 +238,17 @@ enum class ContentKind : Kind {
companion object {
private val platformTagged =
- setOf(Constructors, Functions, Properties, Classlikes, Packages, Source, TypeAliases, Inheritors, Extensions)
+ setOf(
+ Constructors,
+ Functions,
+ Properties,
+ Classlikes,
+ Packages,
+ Source,
+ TypeAliases,
+ Inheritors,
+ Extensions
+ )
fun shouldBePlatformTagged(kind: Kind): Boolean = kind in platformTagged
}
diff --git a/core/src/main/kotlin/pages/ContentSourceSet.kt b/core/src/main/kotlin/pages/ContentSourceSet.kt
new file mode 100644
index 00000000..0ff87edb
--- /dev/null
+++ b/core/src/main/kotlin/pages/ContentSourceSet.kt
@@ -0,0 +1,61 @@
+package org.jetbrains.dokka.pages
+
+import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet
+import org.jetbrains.dokka.DokkaSourceSetID
+import org.jetbrains.dokka.Platform
+
+
+data class ContentSourceSet(
+ val sourceSetIDs: CompositeSourceSetID,
+ val displayName: String,
+ val analysisPlatform: Platform
+) {
+ constructor(sourceSet: DokkaSourceSet) : this(
+ sourceSetIDs = CompositeSourceSetID(sourceSet.sourceSetID),
+ displayName = sourceSet.displayName,
+ analysisPlatform = sourceSet.analysisPlatform
+ )
+
+ operator fun contains(sourceSetID: DokkaSourceSetID): Boolean {
+ return sourceSetID in sourceSetIDs
+ }
+
+ operator fun contains(sourceSet: DokkaSourceSet): Boolean {
+ return sourceSet.sourceSetID in this
+ }
+}
+
+
+//TODO NOW: Test
+data class CompositeSourceSetID(
+ private val children: Set<DokkaSourceSetID>
+) {
+ constructor(sourceSetIDs: Iterable<DokkaSourceSetID>) : this(sourceSetIDs.toSet())
+ constructor(sourceSetId: DokkaSourceSetID) : this(setOf(sourceSetId))
+
+ init {
+ require(children.isNotEmpty()) { "Expected at least one source set id" }
+ }
+
+ val merged = DokkaSourceSetID(
+ moduleName = children.map { it.moduleName }.reduce { acc, s -> "$acc+$s" },
+ sourceSetName = children.map { it.sourceSetName }.reduce { acc, s -> "$acc+$s" }
+ )
+
+ val all: List<DokkaSourceSetID> = listOf(merged, *children.toTypedArray())
+
+ operator fun contains(sourceSetId: DokkaSourceSetID): Boolean {
+ return sourceSetId in all
+ }
+
+ operator fun contains(sourceSet: DokkaSourceSet): Boolean {
+ return sourceSet.sourceSetID in this
+ }
+}
+
+
+fun DokkaSourceSet.toContentSourceSet(): ContentSourceSet = ContentSourceSet(this)
+
+fun Iterable<DokkaSourceSet>.toContentSourceSets(): Set<ContentSourceSet> = map { it.toContentSourceSet() }.toSet()
+
+val Iterable<ContentSourceSet>.sourceSetIDs: List<DokkaSourceSetID> get() = this.flatMap { it.sourceSetIDs.all }
diff --git a/core/src/main/kotlin/pages/PageNodes.kt b/core/src/main/kotlin/pages/PageNodes.kt
index 71ec8597..d49f9911 100644
--- a/core/src/main/kotlin/pages/PageNodes.kt
+++ b/core/src/main/kotlin/pages/PageNodes.kt
@@ -5,8 +5,9 @@ import org.jetbrains.dokka.model.Documentable
import org.jetbrains.dokka.model.WithChildren
import java.util.*
-interface PageNode: WithChildren<PageNode> {
+interface PageNode : WithChildren<PageNode> {
val name: String
+ override val children: List<PageNode>
fun modified(
name: String = this.name,
@@ -14,7 +15,7 @@ interface PageNode: WithChildren<PageNode> {
): PageNode
}
-interface ContentPage: PageNode {
+interface ContentPage : PageNode {
val content: ContentNode
val dri: Set<DRI>
val documentable: Documentable?
@@ -29,11 +30,11 @@ interface ContentPage: PageNode {
): ContentPage
}
-abstract class RootPageNode: PageNode {
+abstract class RootPageNode : PageNode {
val parentMap: Map<PageNode, PageNode> by lazy {
IdentityHashMap<PageNode, PageNode>().apply {
fun process(parent: PageNode) {
- parent.children.forEach { child ->
+ parent.children.forEach { child ->
put(child, parent)
process(child)
}
@@ -171,11 +172,11 @@ class MultimoduleRootPageNode(
embeddedResources: List<String>,
children: List<PageNode>
) =
- if (name == this.name && content === this.content && embeddedResources === this.embeddedResources && children shallowEq this.children) this
- else MultimoduleRootPageNode(name, dri, content, embeddedResources)
+ if (name == this.name && content === this.content && embeddedResources === this.embeddedResources && children shallowEq this.children) this
+ else MultimoduleRootPageNode(name, dri, content, embeddedResources)
}
-inline fun <reified T: PageNode> PageNode.children() = children.filterIsInstance<T>()
+inline fun <reified T : PageNode> PageNode.children() = children.filterIsInstance<T>()
private infix fun <T> List<T>.shallowEq(other: List<T>) =
this === other || (this.size == other.size && (this zip other).all { (a, b) -> a === b })
diff --git a/core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt b/core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt
index 3eb4704e..d0570c7a 100644
--- a/core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt
+++ b/core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt
@@ -1,8 +1,9 @@
package org.jetbrains.dokka.transformers.documentation
import org.jetbrains.dokka.model.DModule
+import org.jetbrains.dokka.model.Documentable
import org.jetbrains.dokka.plugability.DokkaContext
interface DocumentableTransformer {
operator fun invoke(original: DModule, context: DokkaContext): DModule
-} \ No newline at end of file
+}
diff --git a/core/src/main/kotlin/transformers/pages/PageTransformer.kt b/core/src/main/kotlin/transformers/pages/PageTransformer.kt
index 218d9821..086f6d22 100644
--- a/core/src/main/kotlin/transformers/pages/PageTransformer.kt
+++ b/core/src/main/kotlin/transformers/pages/PageTransformer.kt
@@ -1,7 +1,19 @@
package org.jetbrains.dokka.transformers.pages
+import org.jetbrains.dokka.pages.ContentNode
import org.jetbrains.dokka.pages.RootPageNode
interface PageTransformer {
operator fun invoke(input: RootPageNode): RootPageNode
-} \ No newline at end of file
+}
+
+object SourceSetMergePageTransformer : PageTransformer {
+ override fun invoke(input: RootPageNode): RootPageNode {
+
+ return input.transformContentPagesTree { contentPage ->
+ val content: ContentNode = contentPage.content
+ TODO()
+ }
+ }
+
+}
diff --git a/core/src/test/kotlin/model/CompositeSourceSetIDTest.kt b/core/src/test/kotlin/model/CompositeSourceSetIDTest.kt
new file mode 100644
index 00000000..68af259d
--- /dev/null
+++ b/core/src/test/kotlin/model/CompositeSourceSetIDTest.kt
@@ -0,0 +1,58 @@
+package model
+
+import org.jetbrains.dokka.DokkaSourceSetID
+import org.jetbrains.dokka.pages.CompositeSourceSetID
+import kotlin.test.*
+
+class CompositeSourceSetIDTest {
+
+ @Test
+ fun `constructor fails with empty collection`() {
+ assertFailsWith<IllegalArgumentException>("Expected no construction of empty `CompositeSourceSetID`") {
+ CompositeSourceSetID(emptyList())
+ }
+ }
+
+ @Test
+ fun `merged for single source set`() {
+ val sourceSetID = DokkaSourceSetID("module", "sourceSet")
+ val composite = CompositeSourceSetID(sourceSetID)
+
+ assertEquals(
+ composite.merged, sourceSetID,
+ "Expected merged source set id to be equal to single child"
+ )
+ }
+
+ @Test
+ fun `merged with multiple source sets`() {
+ val composite = CompositeSourceSetID(
+ listOf(DokkaSourceSetID("m1", "s1"), DokkaSourceSetID("m2", "s2"), DokkaSourceSetID("m3", "s3"))
+ )
+
+ assertEquals(
+ DokkaSourceSetID("m1+m2+m3", "s1+s2+s3"), composite.merged,
+ "Expected merged source set id to concatenate source sets"
+ )
+ }
+
+ @Test
+ fun `contains with child sourceSetID`() {
+ val composite = CompositeSourceSetID(listOf(DokkaSourceSetID("m1", "s1"), DokkaSourceSetID("m2", "s2")))
+
+ assertFalse(
+ DokkaSourceSetID("m3", "s3") in composite,
+ "Expected source set id not being contained in composite"
+ )
+
+ assertTrue(
+ DokkaSourceSetID("m1", "s1") in composite,
+ "Expected child source set id being contained in composite"
+ )
+
+ assertTrue(
+ DokkaSourceSetID("m1+m2", "s1+s2") in composite,
+ "Expected merged source set id being contained in composite"
+ )
+ }
+}
diff --git a/core/src/test/kotlin/model/ContentSourceSetTest.kt b/core/src/test/kotlin/model/ContentSourceSetTest.kt
new file mode 100644
index 00000000..cb17bcba
--- /dev/null
+++ b/core/src/test/kotlin/model/ContentSourceSetTest.kt
@@ -0,0 +1,61 @@
+package model
+
+import org.jetbrains.dokka.DokkaSourceSetID
+import org.jetbrains.dokka.Platform
+import org.jetbrains.dokka.pages.CompositeSourceSetID
+import org.jetbrains.dokka.pages.ContentSourceSet
+import org.jetbrains.dokka.pages.sourceSetIDs
+import kotlin.test.Test
+import kotlin.test.assertFalse
+import kotlin.test.assertTrue
+
+class ContentSourceSetTest {
+ @Test
+ fun `contains sourceSetId`() {
+ val contentSourceSet = ContentSourceSet(
+ sourceSetIDs = CompositeSourceSetID(listOf(DokkaSourceSetID("m1", "s1"), DokkaSourceSetID("m2", "s2"))),
+ displayName = "displayName",
+ analysisPlatform = Platform.common
+ )
+
+ assertFalse(
+ DokkaSourceSetID("m3", "s3") in contentSourceSet,
+ "Expected source set id not being contained in content source set"
+ )
+
+ assertTrue(
+ DokkaSourceSetID("m1", "s1") in contentSourceSet,
+ "Expected source set id being contained in content source set"
+ )
+
+ assertTrue(
+ DokkaSourceSetID("m1+m2", "s1+s2") in contentSourceSet,
+ "Expected merged source set being contained in content source set"
+ )
+ }
+
+ @Test
+ fun `Iterable contains sourceSetId`() {
+
+ val contentSourceSet = ContentSourceSet(
+ sourceSetIDs = CompositeSourceSetID(listOf(DokkaSourceSetID("m1", "s1"), DokkaSourceSetID("m2", "s2"))),
+ displayName = "displayName",
+ analysisPlatform = Platform.common
+ )
+
+ assertFalse(
+ DokkaSourceSetID("m3", "s3") in listOf(contentSourceSet).sourceSetIDs,
+ "Expected source set id not being contained in content source set"
+ )
+
+ assertTrue(
+ DokkaSourceSetID("m1", "s1") in listOf(contentSourceSet).sourceSetIDs,
+ "Expected source set id being contained in content source set"
+ )
+
+ assertTrue(
+ DokkaSourceSetID("m1+m2", "s1+s2") in listOf(contentSourceSet).sourceSetIDs,
+ "Expected merged source set being contained in content source set"
+ )
+ }
+}
diff --git a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
index afee1b33..84be6df0 100644
--- a/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/DefaultRenderer.kt
@@ -4,7 +4,6 @@ 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.pages.*
@@ -30,7 +29,7 @@ abstract class DefaultRenderer<T>(
abstract fun T.buildList(
node: ContentList,
pageContext: ContentPage,
- sourceSetRestriction: Set<DokkaSourceSet>? = null
+ sourceSetRestriction: Set<ContentSourceSet>? = null
)
abstract fun T.buildNewLine()
@@ -38,7 +37,7 @@ abstract class DefaultRenderer<T>(
abstract fun T.buildTable(
node: ContentTable,
pageContext: ContentPage,
- sourceSetRestriction: Set<DokkaSourceSet>? = null
+ sourceSetRestriction: Set<ContentSourceSet>? = null
)
abstract fun T.buildText(textNode: ContentText)
@@ -50,13 +49,13 @@ abstract class DefaultRenderer<T>(
open fun T.buildPlatformDependent(
content: PlatformHintedContent,
pageContext: ContentPage,
- sourceSetRestriction: Set<DokkaSourceSet>?
+ sourceSetRestriction: Set<ContentSourceSet>?
) = buildContentNode(content.inner, pageContext)
open fun T.buildGroup(
node: ContentGroup,
pageContext: ContentPage,
- sourceSetRestriction: Set<DokkaSourceSet>? = null
+ sourceSetRestriction: Set<ContentSourceSet>? = null
) =
wrapGroup(node, pageContext) { node.children.forEach { it.build(this, pageContext, sourceSetRestriction) } }
@@ -69,7 +68,7 @@ abstract class DefaultRenderer<T>(
open fun T.buildLinkText(
nodes: List<ContentNode>,
pageContext: ContentPage,
- sourceSetRestriction: Set<DokkaSourceSet>? = null
+ sourceSetRestriction: Set<ContentSourceSet>? = null
) {
nodes.forEach { it.build(this, pageContext, sourceSetRestriction) }
}
@@ -85,7 +84,7 @@ abstract class DefaultRenderer<T>(
open fun T.buildHeader(
node: ContentHeader,
pageContext: ContentPage,
- sourceSetRestriction: Set<DokkaSourceSet>? = null
+ sourceSetRestriction: Set<ContentSourceSet>? = null
) {
buildHeader(node.level, node) { node.children.forEach { it.build(this, pageContext, sourceSetRestriction) } }
}
@@ -93,14 +92,14 @@ abstract class DefaultRenderer<T>(
open fun ContentNode.build(
builder: T,
pageContext: ContentPage,
- sourceSetRestriction: Set<DokkaSourceSet>? = null
+ sourceSetRestriction: Set<ContentSourceSet>? = null
) =
builder.buildContentNode(this, pageContext, sourceSetRestriction)
open fun T.buildContentNode(
node: ContentNode,
pageContext: ContentPage,
- sourceSetRestriction: Set<DokkaSourceSet>? = null
+ sourceSetRestriction: Set<ContentSourceSet>? = null
) {
if (sourceSetRestriction == null || node.sourceSets.any { it in sourceSetRestriction }) {
when (node) {
@@ -178,8 +177,8 @@ abstract class DefaultRenderer<T>(
protected fun ContentDivergentGroup.groupDivergentInstances(
pageContext: ContentPage,
- beforeTransformer: (ContentDivergentInstance, ContentPage, DokkaSourceSet) -> String,
- afterTransformer: (ContentDivergentInstance, ContentPage, DokkaSourceSet) -> String
+ beforeTransformer: (ContentDivergentInstance, ContentPage, ContentSourceSet) -> String,
+ afterTransformer: (ContentDivergentInstance, ContentPage, ContentSourceSet) -> String
): Map<SerializedBeforeAndAfter, List<InstanceWithSource>> =
children.flatMap { instance ->
instance.sourceSets.map { sourceSet ->
@@ -195,6 +194,6 @@ abstract class DefaultRenderer<T>(
}
internal typealias SerializedBeforeAndAfter = Pair<String, String>
-internal typealias InstanceWithSource = Pair<ContentDivergentInstance, DokkaSourceSet>
+internal typealias InstanceWithSource = Pair<ContentDivergentInstance, ContentSourceSet>
-fun ContentPage.sourceSets() = this.content.sourceSets \ No newline at end of file
+fun ContentPage.sourceSets() = this.content.sourceSets
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
index 88d2539d..c533836a 100644
--- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
+++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt
@@ -5,7 +5,6 @@ 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
@@ -111,7 +110,7 @@ open class HtmlRenderer(
page.content.withDescendants().flatMap { it.sourceSets }.distinct().forEach {
button(classes = "platform-tag platform-selector") {
attributes["data-active"] = ""
- attributes["data-filter"] = it.sourceSetID.toString()
+ attributes["data-filter"] = it.sourceSetIDs.merged.toString()
when (it.analysisPlatform.key) {
"common" -> classes = classes + "common-like"
"native" -> classes = classes + "native-like"
@@ -157,7 +156,7 @@ open class HtmlRenderer(
override fun FlowContent.buildPlatformDependent(
content: PlatformHintedContent,
pageContext: ContentPage,
- sourceSetRestriction: Set<DokkaSourceSet>?
+ sourceSetRestriction: Set<ContentSourceSet>?
) =
buildPlatformDependent(
content.sourceSets.filter {
@@ -169,7 +168,7 @@ open class HtmlRenderer(
)
private fun FlowContent.buildPlatformDependent(
- nodes: Map<DokkaSourceSet, Collection<ContentNode>>,
+ nodes: Map<ContentSourceSet, Collection<ContentNode>>,
pageContext: ContentPage,
extra: PropertyContainer<ContentNode> = PropertyContainer.empty(),
styles: Set<Style> = emptySet()
@@ -186,17 +185,17 @@ open class HtmlRenderer(
attributes["data-toggle-list"] = "data-toggle-list"
contents.forEachIndexed { index, pair ->
button(classes = "platform-bookmark") {
- attributes["data-filterable-current"] = pair.first.sourceSetID.toString()
- attributes["data-filterable-set"] = pair.first.sourceSetID.toString()
+ attributes["data-filterable-current"] = pair.first.sourceSetIDs.merged.toString()
+ attributes["data-filterable-set"] = pair.first.sourceSetIDs.merged.toString()
if (index == 0) attributes["data-active"] = ""
- attributes["data-toggle"] = pair.first.sourceSetID.toString()
+ attributes["data-toggle"] = pair.first.sourceSetIDs.merged.toString()
when (pair.first.analysisPlatform.key) {
"common" -> classes = classes + "common-like"
"native" -> classes = classes + "native-like"
"jvm" -> classes = classes + "jvm-like"
"js" -> classes = classes + "js-like"
}
- attributes["data-toggle"] = pair.first.sourceSetID.toString()
+ attributes["data-toggle"] = pair.first.sourceSetIDs.merged.toString()
text(pair.first.displayName)
}
}
@@ -209,9 +208,9 @@ open class HtmlRenderer(
}
private fun contentsForSourceSetDependent(
- nodes: Map<DokkaSourceSet, Collection<ContentNode>>,
+ nodes: Map<ContentSourceSet, Collection<ContentNode>>,
pageContext: ContentPage,
- ): List<Pair<DokkaSourceSet, String>> {
+ ): List<Pair<ContentSourceSet, String>> {
var counter = 0
return nodes.toList().map { (sourceSet, elements) ->
sourceSet to createHTML(prettyPrint = false).div {
@@ -220,15 +219,15 @@ open class HtmlRenderer(
}
}.stripDiv()
}.groupBy(
- Pair<DokkaSourceSet, String>::second,
- Pair<DokkaSourceSet, String>::first
+ Pair<ContentSourceSet, String>::second,
+ Pair<ContentSourceSet, String>::first
).entries.flatMap { (html, sourceSets) ->
sourceSets.filterNot {
sourceSetDependencyMap[it].orEmpty().any { dependency -> sourceSets.contains(dependency) }
}.map {
it to createHTML(prettyPrint = false).div(classes = "content sourceset-depenent-content") {
if (counter++ == 0) attributes["data-active"] = ""
- attributes["data-togglable"] = it.sourceSetID.toString()
+ attributes["data-togglable"] = it.sourceSetIDs.merged.toString()
unsafe {
+html
}
@@ -260,10 +259,10 @@ open class HtmlRenderer(
consumer.onTagContentUnsafe {
+createHTML().div("divergent-group") {
attributes["data-filterable-current"] = groupedDivergent.keys.joinToString(" ") {
- it.sourceSetID.toString()
+ it.sourceSetIDs.merged.toString()
}
attributes["data-filterable-set"] = groupedDivergent.keys.joinToString(" ") {
- it.sourceSetID.toString()
+ it.sourceSetIDs.merged.toString()
}
val divergentForPlatformDependent = groupedDivergent.map { (sourceSet, elements) ->
@@ -309,14 +308,14 @@ open class HtmlRenderer(
override fun FlowContent.buildList(
node: ContentList,
pageContext: ContentPage,
- sourceSetRestriction: Set<DokkaSourceSet>?
+ sourceSetRestriction: Set<ContentSourceSet>?
) = 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<DokkaSourceSet>? = null
+ sourceSetRestriction: Set<ContentSourceSet>? = null
) {
items.forEach {
if (it is ContentList)
@@ -329,7 +328,7 @@ open class HtmlRenderer(
open fun UL.buildListItems(
items: List<ContentNode>,
pageContext: ContentPage,
- sourceSetRestriction: Set<DokkaSourceSet>? = null
+ sourceSetRestriction: Set<ContentSourceSet>? = null
) {
items.forEach {
if (it is ContentList)
@@ -356,7 +355,7 @@ open class HtmlRenderer(
private fun FlowContent.buildRow(
node: ContentGroup,
pageContext: ContentPage,
- sourceSetRestriction: Set<DokkaSourceSet>?,
+ sourceSetRestriction: Set<ContentSourceSet>?,
style: Set<Style>
) {
node.children
@@ -368,10 +367,10 @@ open class HtmlRenderer(
div(classes = "table-row") {
if (!style.contains(MultimoduleTable)) {
attributes["data-filterable-current"] = node.sourceSets.joinToString(" ") {
- it.sourceSetID.toString()
+ it.sourceSetIDs.merged.toString()
}
attributes["data-filterable-set"] = node.sourceSets.joinToString(" ") {
- it.sourceSetID.toString()
+ it.sourceSetIDs.merged.toString()
}
}
@@ -409,7 +408,7 @@ open class HtmlRenderer(
}
}
- private fun FlowContent.createPlatformTagBubbles(sourceSets: List<DokkaSourceSet>) {
+ private fun FlowContent.createPlatformTagBubbles(sourceSets: List<ContentSourceSet>) {
if (isMultiplatform) {
div("platform-tags") {
sourceSets.forEach {
@@ -427,7 +426,10 @@ open class HtmlRenderer(
}
}
- private fun FlowContent.createPlatformTags(node: ContentNode, sourceSetRestriction: Set<DokkaSourceSet>? = null) {
+ private fun FlowContent.createPlatformTags(
+ node: ContentNode,
+ sourceSetRestriction: Set<ContentSourceSet>? = null
+ ) {
node.takeIf { sourceSetRestriction == null || it.sourceSets.any { s -> s in sourceSetRestriction } }?.let {
createPlatformTagBubbles(node.sourceSets.filter {
sourceSetRestriction == null || it in sourceSetRestriction
@@ -438,7 +440,7 @@ open class HtmlRenderer(
override fun FlowContent.buildTable(
node: ContentTable,
pageContext: ContentPage,
- sourceSetRestriction: Set<DokkaSourceSet>?
+ sourceSetRestriction: Set<ContentSourceSet>?
) {
when (node.dci.kind) {
ContentKind.Comment -> buildDefaultTable(node, pageContext, sourceSetRestriction)
@@ -455,7 +457,7 @@ open class HtmlRenderer(
fun FlowContent.buildDefaultTable(
node: ContentTable,
pageContext: ContentPage,
- sourceSetRestriction: Set<DokkaSourceSet>?
+ sourceSetRestriction: Set<ContentSourceSet>?
) {
table {
thead {
@@ -540,7 +542,7 @@ open class HtmlRenderer(
fun FlowContent.buildLink(
to: DRI,
- platforms: List<DokkaSourceSet>,
+ platforms: List<ContentSourceSet>,
from: PageNode? = null,
block: FlowContent.() -> Unit
) = buildLink(locationProvider.resolve(to, platforms.toSet(), from), block)
@@ -580,7 +582,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: DokkaSourceSet): List<ContentText> =
+ fun getContentTextNodes(node: ContentNode, sourceSetRestriction: ContentSourceSet): List<ContentText> =
when (node) {
is ContentText -> listOf(node)
is ContentComposite -> node.children
@@ -723,7 +725,7 @@ open class HtmlRenderer(
span { text("© 2020 Copyright") }
span("pull-right") {
span { text("Sponsored and developed by dokka") }
- a(href= "https://github.com/Kotlin/dokka") {
+ a(href = "https://github.com/Kotlin/dokka") {
span(classes = "padded-icon") {
unsafe {
raw(
diff --git a/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt b/plugins/base/src/main/kotlin/renderers/html/NavigationPage.kt
index 46295d71..138a8e16 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.DokkaConfiguration.DokkaSourceSet
+import org.jetbrains.dokka.pages.ContentSourceSet
import org.jetbrains.dokka.pages.PageNode
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 sourceSets: Set<DokkaSourceSet>,
+ val sourceSets: Set<ContentSourceSet>,
val children: List<NavigationNode>
)
diff --git a/plugins/base/src/main/kotlin/resolvers/local/BaseLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/BaseLocationProvider.kt
index 4204006e..a9a5e498 100644
--- a/plugins/base/src/main/kotlin/resolvers/local/BaseLocationProvider.kt
+++ b/plugins/base/src/main/kotlin/resolvers/local/BaseLocationProvider.kt
@@ -1,9 +1,10 @@
package org.jetbrains.dokka.base.resolvers.local
import org.jetbrains.dokka.DokkaConfiguration
-import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.links.DRI
+import org.jetbrains.dokka.pages.ContentSourceSet
+import org.jetbrains.dokka.pages.sourceSetIDs
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.plugability.plugin
import org.jetbrains.dokka.plugability.query
@@ -23,12 +24,10 @@ abstract class BaseLocationProvider(protected val dokkaContext: DokkaContext) :
protected fun getExternalLocation(
dri: DRI,
- sourceSets: Set<DokkaSourceSet>
+ sourceSets: Set<ContentSourceSet>
): String {
val jdkToExternalDocumentationLinks = dokkaContext.configuration.sourceSets
- .filter { sourceSet ->
- sourceSets.contains(sourceSet)
- }
+ .filter { sourceSet -> sourceSet.sourceSetID in sourceSets.sourceSetIDs }
.groupBy({ it.jdkVersion }, { it.externalDocumentationLinks })
.map { it.key to it.value.flatten().distinct() }.toMap()
diff --git a/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt
index 1df0a700..0021b7fb 100644
--- a/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt
+++ b/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt
@@ -1,7 +1,6 @@
package org.jetbrains.dokka.base.resolvers.local
import org.jetbrains.dokka.DokkaConfiguration
-import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet
import org.jetbrains.dokka.base.resolvers.anchors.SymbolAnchorHint
import org.jetbrains.dokka.base.resolvers.external.ExternalLocationProvider
import org.jetbrains.dokka.links.DRI
@@ -51,7 +50,7 @@ open class DefaultLocationProvider(
override fun resolve(node: PageNode, context: PageNode?, skipExtension: Boolean): String =
pathTo(node, context) + if (!skipExtension) extension else ""
- override fun resolve(dri: DRI, sourceSets: Set<DokkaSourceSet>, context: PageNode?): String =
+ override fun resolve(dri: DRI, sourceSets: Set<ContentSourceSet>, context: PageNode?): String =
pagesIndex[dri]?.let { resolve(it, context) }
?: anchorsIndex[dri]?.let { resolve(it, context) + "#$dri" }
// Not found in PageGraph, that means it's an external link
diff --git a/plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt
index 745636d0..bf5d9be4 100644
--- a/plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt
+++ b/plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt
@@ -1,12 +1,12 @@
package org.jetbrains.dokka.base.resolvers.local
import org.jetbrains.dokka.links.DRI
-import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet
+import org.jetbrains.dokka.pages.ContentSourceSet
import org.jetbrains.dokka.pages.PageNode
import org.jetbrains.dokka.pages.RootPageNode
interface LocationProvider {
- fun resolve(dri: DRI, sourceSets: Set<DokkaSourceSet>, context: PageNode? = null): String
+ fun resolve(dri: DRI, sourceSets: Set<ContentSourceSet>, context: PageNode? = null): String
fun resolve(node: PageNode, context: PageNode? = null, skipExtension: Boolean = false): String
fun resolveRoot(node: PageNode): String
fun ancestors(node: PageNode): List<PageNode>
diff --git a/plugins/base/src/main/kotlin/resolvers/local/MultimoduleLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/MultimoduleLocationProvider.kt
index 54aded35..c5e16cc3 100644
--- a/plugins/base/src/main/kotlin/resolvers/local/MultimoduleLocationProvider.kt
+++ b/plugins/base/src/main/kotlin/resolvers/local/MultimoduleLocationProvider.kt
@@ -1,7 +1,7 @@
package org.jetbrains.dokka.base.resolvers.local
import org.jetbrains.dokka.links.DRI
-import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet
+import org.jetbrains.dokka.pages.ContentSourceSet
import org.jetbrains.dokka.pages.PageNode
import org.jetbrains.dokka.pages.RootPageNode
import org.jetbrains.dokka.plugability.DokkaContext
@@ -14,7 +14,7 @@ class MultimoduleLocationProvider(private val root: RootPageNode, context: Dokka
it.name to it.path
}.toMap()
- override fun resolve(dri: DRI, sourceSets: Set<DokkaSourceSet>, context: PageNode?): String =
+ override fun resolve(dri: DRI, sourceSets: Set<ContentSourceSet>, context: PageNode?): String =
dri.takeIf { it.packageName == MULTIMODULE_PACKAGE_PLACEHOLDER }?.classNames?.let { paths[it] }?.let {
"$it/${identifierToFilename(dri.classNames.orEmpty())}/index.html"
} ?: defaultLocationProvider.resolve(dri, sourceSets, context)
diff --git a/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt b/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt
index 9d667623..3d9a9993 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/comments/DocTagToContentConverter.kt
@@ -30,7 +30,7 @@ object DocTagToContentConverter : CommentsToContentConverter {
buildChildren(docTag),
level,
dci,
- sourceSets,
+ sourceSets.toContentSourceSets(),
styles
)
)
@@ -41,7 +41,7 @@ object DocTagToContentConverter : CommentsToContentConverter {
buildChildren(docTag),
ordered,
dci,
- sourceSets,
+ sourceSets.toContentSourceSets(),
styles,
((PropertyContainer.empty<ContentNode>()) + SimpleAttr("start", start.toString()))
)
@@ -49,7 +49,7 @@ object DocTagToContentConverter : CommentsToContentConverter {
fun buildNewLine() = listOf(
ContentBreakLine(
- sourceSets
+ sourceSets.toContentSourceSets()
)
)
@@ -66,20 +66,26 @@ object DocTagToContentConverter : CommentsToContentConverter {
is Ul -> buildList(false)
is Ol -> buildList(true, docTag.params["start"]?.toInt() ?: 1)
is Li -> listOf(
- ContentGroup(buildChildren(docTag), dci, sourceSets, styles, extra)
+ ContentGroup(buildChildren(docTag), dci, sourceSets.toContentSourceSets(), styles, extra)
)
is Br -> buildNewLine()
is B -> buildChildren(docTag, setOf(TextStyle.Strong))
is I -> buildChildren(docTag, setOf(TextStyle.Italic))
is P -> listOf(
- ContentGroup(buildChildren(docTag.collapseParagraphs()), dci, sourceSets, styles + setOf(TextStyle.Paragraph), extra)
+ ContentGroup(
+ buildChildren(docTag.collapseParagraphs()),
+ dci,
+ sourceSets.toContentSourceSets(),
+ styles + setOf(TextStyle.Paragraph),
+ extra
+ )
)
is A -> listOf(
ContentResolvedLink(
buildChildren(docTag),
- docTag.params.get("href")!!,
+ docTag.params.getValue("href"),
dci,
- sourceSets,
+ sourceSets.toContentSourceSets(),
styles
)
)
@@ -91,7 +97,7 @@ object DocTagToContentConverter : CommentsToContentConverter {
setOf(docTag.dri),
ContentKind.Main
),
- sourceSets,
+ sourceSets.toContentSourceSets(),
styles
)
)
@@ -100,7 +106,7 @@ object DocTagToContentConverter : CommentsToContentConverter {
buildChildren(docTag),
"",
dci,
- sourceSets,
+ sourceSets.toContentSourceSets(),
styles
)
)
@@ -109,7 +115,7 @@ object DocTagToContentConverter : CommentsToContentConverter {
buildChildren(docTag),
"",
dci,
- sourceSets,
+ sourceSets.toContentSourceSets(),
styles
)
)
@@ -118,7 +124,7 @@ object DocTagToContentConverter : CommentsToContentConverter {
buildChildren(docTag),
"",
dci,
- sourceSets,
+ sourceSets.toContentSourceSets(),
styles
)
)
@@ -127,7 +133,7 @@ object DocTagToContentConverter : CommentsToContentConverter {
address = docTag.params["href"]!!,
altText = docTag.params["alt"],
dci = dci,
- sourceSets = sourceSets,
+ sourceSets = sourceSets.toContentSourceSets(),
style = styles,
extra = extra
)
@@ -136,7 +142,7 @@ object DocTagToContentConverter : CommentsToContentConverter {
ContentText(
"",
dci,
- sourceSets,
+ sourceSets.toContentSourceSets(),
setOf()
)
)
@@ -144,7 +150,7 @@ object DocTagToContentConverter : CommentsToContentConverter {
ContentText(
docTag.body,
dci,
- sourceSets,
+ sourceSets.toContentSourceSets(),
styles
)
)
@@ -154,7 +160,7 @@ object DocTagToContentConverter : CommentsToContentConverter {
buildTableRows(docTag.children.filterIsInstance<Th>(), CommentTable),
buildTableRows(docTag.children.filterIsInstance<Tr>(), CommentTable),
dci,
- sourceSets,
+ sourceSets.toContentSourceSets(),
styles + CommentTable
)
)
@@ -162,10 +168,10 @@ object DocTagToContentConverter : CommentsToContentConverter {
is Tr -> listOf(
ContentGroup(
docTag.children.map {
- ContentGroup(buildChildren(it), dci, sourceSets, styles, extra)
+ ContentGroup(buildChildren(it), dci, sourceSets.toContentSourceSets(), styles, extra)
},
dci,
- sourceSets,
+ sourceSets.toContentSourceSets(),
styles
)
)
@@ -173,7 +179,7 @@ object DocTagToContentConverter : CommentsToContentConverter {
ContentGroup(
buildChildren(docTag, newStyles = styles + ContentStyle.InDocumentationAnchor),
dci,
- sourceSets,
+ sourceSets.toContentSourceSets(),
styles
)
)
diff --git a/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt
index f13e52ab..1eecb114 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt
@@ -125,7 +125,7 @@ abstract class SamplesTransformer(val context: DokkaContext) : PageTransformer {
}
private fun contentCode(
- sourceSets: Set<DokkaSourceSet>,
+ sourceSets: Set<ContentSourceSet>,
dri: Set<DRI>,
content: String,
language: String,
diff --git a/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt
index da2859d9..0488f4e0 100644
--- a/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt
+++ b/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt
@@ -66,7 +66,7 @@ class SourceLinksTransformer(val context: DokkaContext, val builder: PageContent
}
},
DCI(node.dri, ContentKind.Source),
- node.documentable!!.sourceSets.toSet(),
+ node.documentable!!.sourceSets.toContentSourceSets(),
style = emptySet(),
extra = mainExtra + SimpleAttr.header("Sources")
)
diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
index 02f4b54e..04b29990 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
@@ -159,7 +159,7 @@ open class DefaultPageCreator(
}
},
DCI(setOf(dri), ContentKind.Inheritors),
- sourceSets.toSet(),
+ sourceSets.toContentSourceSets(),
style = emptySet(),
extra = mainExtra + SimpleAttr.header("Inheritors")
)
diff --git a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt
index b7927076..a556a96e 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt
@@ -73,7 +73,7 @@ open class PageContentBuilder(
) = ContentGroup(
contents.toList(),
DCI(mainDRI, kind),
- sourceSets,
+ sourceSets.toContentSourceSets(),
styles,
extra
)
@@ -88,10 +88,10 @@ open class PageContentBuilder(
private val defaultHeaders
get() = listOf(
- contentFor(mainDRI, mainSourcesetData){
+ contentFor(mainDRI, mainSourcesetData) {
text("Name")
},
- contentFor(mainDRI, mainSourcesetData){
+ contentFor(mainDRI, mainSourcesetData) {
text("Summary")
}
)
@@ -153,7 +153,7 @@ open class PageContentBuilder(
defaultHeaders,
operation(),
DCI(mainDRI, kind),
- sourceSets, styles, extra
+ sourceSets.toContentSourceSets(), styles, extra
)
}
@@ -188,7 +188,7 @@ open class PageContentBuilder(
}
},
DCI(mainDRI, kind),
- sourceSets, styles, extra
+ sourceSets.toContentSourceSets(), styles, extra
)
}
}
@@ -234,7 +234,7 @@ open class PageContentBuilder(
listOf(createText(text, kind, sourceSets, styles, extra)),
address,
DCI(mainDRI, kind),
- sourceSets
+ sourceSets.toContentSourceSets()
)
fun link(
@@ -250,7 +250,7 @@ open class PageContentBuilder(
address = address,
extra = PropertyContainer.empty(),
dci = DCI(mainDRI, kind),
- sourceSets = sourceSets,
+ sourceSets = sourceSets.toContentSourceSets(),
style = emptySet()
)
}
@@ -267,7 +267,7 @@ open class PageContentBuilder(
contentFor(mainDRI, sourceSets, kind, styles, extra, block).children,
address,
DCI(mainDRI, kind),
- sourceSets
+ sourceSets.toContentSourceSets()
)
}
@@ -283,7 +283,7 @@ open class PageContentBuilder(
DCI(mainDRI, kind),
sourceSets
)
- contents += ContentGroup(content, DCI(mainDRI, kind), sourceSets, styles, extra)
+ contents += ContentGroup(content, DCI(mainDRI, kind), sourceSets.toContentSourceSets(), styles, extra)
}
fun group(
@@ -331,7 +331,7 @@ open class PageContentBuilder(
) {
contents += PlatformHintedContent(
buildGroup(dri, sourceSets, kind, styles, extra, block),
- sourceSets
+ sourceSets.toContentSourceSets()
)
}
@@ -345,7 +345,7 @@ open class PageContentBuilder(
) {
contents += PlatformHintedContent(
buildGroup(setOf(dri), sourcesetData, kind, styles, extra, block),
- sourcesetData
+ sourcesetData.toContentSourceSets()
)
}
@@ -356,7 +356,7 @@ open class PageContentBuilder(
styles: Set<Style>,
extra: PropertyContainer<ContentNode>
) =
- ContentText(text, DCI(mainDRI, kind), sourceSets, styles, extra)
+ ContentText(text, DCI(mainDRI, kind), sourceSets.toContentSourceSets(), styles, extra)
fun <T> sourceSetDependentText(
value: SourceSetDependent<T>,
@@ -466,9 +466,9 @@ open class PageContentBuilder(
divergent ?: throw IllegalStateException("Divergent block needs divergent part"),
after,
DCI(mainDRI, kind),
- sourceSets,
+ sourceSets.toContentSourceSets(),
styles,
extra
)
}
-} \ No newline at end of file
+}
diff --git a/plugins/gfm/src/main/kotlin/GfmPlugin.kt b/plugins/gfm/src/main/kotlin/GfmPlugin.kt
index dcc9c0a6..20a8662d 100644
--- a/plugins/gfm/src/main/kotlin/GfmPlugin.kt
+++ b/plugins/gfm/src/main/kotlin/GfmPlugin.kt
@@ -1,7 +1,6 @@
package org.jetbrains.dokka.gfm
import org.jetbrains.dokka.CoreExtensions
-import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.renderers.DefaultRenderer
import org.jetbrains.dokka.base.renderers.PackageListCreator
@@ -85,7 +84,7 @@ open class CommonmarkRenderer(
override fun StringBuilder.buildList(
node: ContentList,
pageContext: ContentPage,
- sourceSetRestriction: Set<DokkaSourceSet>?
+ sourceSetRestriction: Set<ContentSourceSet>?
) {
buildListLevel(node, pageContext)
}
@@ -125,14 +124,14 @@ open class CommonmarkRenderer(
override fun StringBuilder.buildPlatformDependent(
content: PlatformHintedContent,
pageContext: ContentPage,
- sourceSetRestriction: Set<DokkaSourceSet>?
+ sourceSetRestriction: Set<ContentSourceSet>?
) {
buildPlatformDependentItem(content.inner, content.sourceSets, pageContext)
}
private fun StringBuilder.buildPlatformDependentItem(
content: ContentNode,
- sourceSets: Set<DokkaSourceSet>,
+ sourceSets: Set<ContentSourceSet>,
pageContext: ContentPage,
) {
if (content is ContentGroup && content.children.firstOrNull { it is ContentTable } != null) {
@@ -140,7 +139,7 @@ open class CommonmarkRenderer(
} else {
val distinct = sourceSets.map {
it to buildString { buildContentNode(content, pageContext, setOf(it)) }
- }.groupBy(Pair<DokkaSourceSet, String>::second, Pair<DokkaSourceSet, String>::first)
+ }.groupBy(Pair<ContentSourceSet, String>::second, Pair<ContentSourceSet, String>::first)
distinct.filter { it.key.isNotBlank() }.forEach { (text, platforms) ->
append(" ")
@@ -158,7 +157,7 @@ open class CommonmarkRenderer(
override fun StringBuilder.buildTable(
node: ContentTable,
pageContext: ContentPage,
- sourceSetRestriction: Set<DokkaSourceSet>?
+ sourceSetRestriction: Set<ContentSourceSet>?
) {
buildNewLine()
if (node.dci.kind == ContentKind.Sample || node.dci.kind == ContentKind.Parameters) {
@@ -198,7 +197,12 @@ open class CommonmarkRenderer(
val builder = StringBuilder()
it.children.forEach {
builder.append("| ")
- builder.append(buildString { it.build(this, pageContext) }.replace(Regex("#+ "), "") ) // Workaround for headers inside tables
+ builder.append(
+ buildString { it.build(this, pageContext) }.replace(
+ Regex("#+ "),
+ ""
+ )
+ ) // Workaround for headers inside tables
}
append(builder.toString().withEntersAsHtml())
append(" | ".repeat(size - it.children.size))
@@ -208,9 +212,9 @@ open class CommonmarkRenderer(
}
override fun StringBuilder.buildText(textNode: ContentText) {
- if(textNode.text.isNotBlank()) {
+ if (textNode.text.isNotBlank()) {
val decorators = decorators(textNode.style)
- append(textNode.text.takeWhile { it == ' ' } )
+ append(textNode.text.takeWhile { it == ' ' })
append(decorators)
append(textNode.text.trim())
append(decorators.reversed())
@@ -257,7 +261,11 @@ open class CommonmarkRenderer(
instance.before?.let {
append("Brief description")
buildNewLine()
- buildContentNode(it, pageContext, setOf(sourceSets.first())) // It's workaround to render content only once
+ buildContentNode(
+ it,
+ pageContext,
+ setOf(sourceSets.first())
+ ) // It's workaround to render content only once
buildNewLine()
}
@@ -266,18 +274,26 @@ open class CommonmarkRenderer(
entry.groupBy { buildString { buildContentNode(it.first.divergent, pageContext, setOf(it.second)) } }
.values.forEach { innerEntry ->
val (innerInstance, innerSourceSets) = innerEntry.getInstanceAndSourceSets()
- if(sourceSets.size > 1) {
+ if (sourceSets.size > 1) {
buildSourceSetTags(innerSourceSets)
buildNewLine()
}
- innerInstance.divergent.build(this@buildDivergent, pageContext, setOf(innerSourceSets.first())) // It's workaround to render content only once
+ innerInstance.divergent.build(
+ this@buildDivergent,
+ pageContext,
+ setOf(innerSourceSets.first())
+ ) // It's workaround to render content only once
buildNewLine()
}
instance.after?.let {
append("More info")
buildNewLine()
- buildContentNode(it, pageContext, setOf(sourceSets.first())) // It's workaround to render content only once
+ buildContentNode(
+ it,
+ pageContext,
+ setOf(sourceSets.first())
+ ) // It's workaround to render content only once
buildNewLine()
}
@@ -323,9 +339,10 @@ open class CommonmarkRenderer(
private fun String.withEntersAsHtml(): String = replace("\n", "<br>")
- private fun List<Pair<ContentDivergentInstance, DokkaSourceSet>>.getInstanceAndSourceSets() = this.let { Pair(it.first().first, it.map { it.second }.toSet()) }
+ private fun List<Pair<ContentDivergentInstance, ContentSourceSet>>.getInstanceAndSourceSets() =
+ this.let { Pair(it.first().first, it.map { it.second }.toSet()) }
- private fun StringBuilder.buildSourceSetTags(sourceSets: Set<DokkaSourceSet>) =
+ private fun StringBuilder.buildSourceSetTags(sourceSets: Set<ContentSourceSet>) =
append(sourceSets.joinToString(prefix = "[", postfix = "]") { it.displayName })
}
diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt
index b3bb49d3..a72544e2 100644
--- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt
+++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt
@@ -75,7 +75,7 @@ open class JavadocPageCreator(
JavadocContentGroup(
setOf(m.dri),
JavadocContentKind.OverviewSummary,
- m.jvmSourceSets.toSet()
+ m.jvmSourceSets.toContentSourceSets()
) {
title(m.name, m.brief(), "0.0.1", dri = setOf(m.dri), kind = ContentKind.Main)
leafList(setOf(m.dri),
@@ -94,7 +94,7 @@ open class JavadocPageCreator(
JavadocContentGroup(
setOf(p.dri),
JavadocContentKind.PackageSummary,
- p.jvmSourceSets.toSet()
+ p.jvmSourceSets.toContentSourceSets()
) {
title(p.name, p.brief(), "0.0.1", dri = setOf(p.dri), kind = ContentKind.Packages)
val rootList = p.classlikes.groupBy { it::class }.map { (key, value) ->
@@ -109,7 +109,7 @@ open class JavadocPageCreator(
}
private val KClass<out DClasslike>.colTitle: String
- get() = when(this) {
+ get() = when (this) {
DClass::class -> "Class"
DObject::class -> "Object"
DAnnotation::class -> "Annotation"
@@ -125,7 +125,7 @@ open class JavadocPageCreator(
JavadocContentGroup(
setOf(c.dri),
JavadocContentKind.Class,
- c.jvmSourceSets.toSet()
+ c.jvmSourceSets.toContentSourceSets()
) {
title(
c.name.orEmpty(),
@@ -190,7 +190,7 @@ open class JavadocPageCreator(
}.orEmpty()
fun List<ContentNode>.nodeForJvm(jvm: DokkaSourceSet): ContentNode =
- first { it.sourceSets.contains(jvm) }
+ first { jvm.sourceSetID in it.sourceSets.sourceSetIDs }
private fun Documentable.brief(sourceSet: DokkaSourceSet? = highestJvmSourceSet): List<ContentNode> =
briefFromContentNodes(descriptionToContentNodes(sourceSet))
@@ -224,7 +224,8 @@ open class JavadocPageCreator(
signatureProvider.signature(documentable).nodeForJvm(sourceSet).asJavadocNode()
private fun Documentable.indexesInDocumentation(): JavadocIndexExtra {
- val indexes = documentation[highestJvmSourceSet]?.withDescendants()?.filterIsInstance<Index>()?.toList().orEmpty()
+ val indexes =
+ documentation[highestJvmSourceSet]?.withDescendants()?.filterIsInstance<Index>()?.toList().orEmpty()
return JavadocIndexExtra(
indexes.map {
ContentGroup(
@@ -234,7 +235,7 @@ open class JavadocPageCreator(
sourceSets.toSet()
),
dci = DCI(setOf(dri), JavadocContentKind.OverviewSummary),
- sourceSets = sourceSets.toSet(),
+ sourceSets = sourceSets.toContentSourceSets(),
style = emptySet(),
extra = PropertyContainer.empty()
)
diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationProvider.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationProvider.kt
index e0a7768c..c9513967 100644
--- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationProvider.kt
+++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationProvider.kt
@@ -1,13 +1,13 @@
package org.jetbrains.dokka.javadoc.location
import org.jetbrains.dokka.javadoc.pages.*
-import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet
import org.jetbrains.dokka.base.resolvers.local.BaseLocationProvider
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.links.Nullable
import org.jetbrains.dokka.links.parent
import org.jetbrains.dokka.model.*
import org.jetbrains.dokka.pages.ContentPage
+import org.jetbrains.dokka.pages.ContentSourceSet
import org.jetbrains.dokka.pages.PageNode
import org.jetbrains.dokka.pages.RootPageNode
import org.jetbrains.dokka.plugability.DokkaContext
@@ -64,7 +64,7 @@ class JavadocLocationProvider(pageRoot: RootPageNode, dokkaContext: DokkaContext
private fun JavadocClasslikePageNode.findAnchorableByDRI(dri: DRI): AnchorableJavadocNode? =
(constructors + methods + entries + properties).firstOrNull { it.dri == dri }
- override fun resolve(dri: DRI, sourceSets: Set<DokkaSourceSet>, context: PageNode?): String {
+ override fun resolve(dri: DRI, sourceSets: Set<ContentSourceSet>, context: PageNode?): String {
return nodeIndex[dri]?.let { resolve(it, context) }
?: nodeIndex[dri.parent]?.takeIf { it is JavadocClasslikePageNode }?.let {
val anchor = when (val anchorElement = (it as? JavadocClasslikePageNode)?.findAnchorableByDRI(dri)) {
diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocContentNodes.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocContentNodes.kt
index d45837b7..2c9ee013 100644
--- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocContentNodes.kt
+++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocContentNodes.kt
@@ -1,7 +1,6 @@
package org.jetbrains.dokka.javadoc.pages
import org.jetbrains.dokka.links.DRI
-import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet
import org.jetbrains.dokka.model.properties.PropertyContainer
import org.jetbrains.dokka.pages.*
@@ -12,7 +11,7 @@ enum class JavadocContentKind : Kind {
abstract class JavadocContentNode(
dri: Set<DRI>,
kind: Kind,
- override val sourceSets: Set<DokkaSourceSet>
+ override val sourceSets: Set<ContentSourceSet>
) : ContentNode {
override val dci: DCI = DCI(dri, kind)
override val style: Set<Style> = emptySet()
@@ -33,7 +32,7 @@ interface JavadocListEntry {
class EmptyNode(
dri: DRI,
kind: Kind,
- override val sourceSets: Set<DokkaSourceSet>,
+ override val sourceSets: Set<ContentSourceSet>,
override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
) : ContentNode {
override val dci: DCI = DCI(setOf(dri), kind)
@@ -48,7 +47,7 @@ class EmptyNode(
class JavadocContentGroup(
val dri: Set<DRI>,
val kind: Kind,
- sourceSets: Set<DokkaSourceSet>,
+ sourceSets: Set<ContentSourceSet>,
override val children: List<JavadocContentNode>
) : JavadocContentNode(dri, kind, sourceSets) {
@@ -56,7 +55,7 @@ class JavadocContentGroup(
operator fun invoke(
dri: Set<DRI>,
kind: Kind,
- sourceSets: Set<DokkaSourceSet>,
+ sourceSets: Set<ContentSourceSet>,
block: JavaContentGroupBuilder.() -> Unit
): JavadocContentGroup =
JavadocContentGroup(dri, kind, sourceSets, JavaContentGroupBuilder(sourceSets).apply(block).list)
@@ -65,7 +64,7 @@ class JavadocContentGroup(
override fun hasAnyContent(): Boolean = children.isNotEmpty()
}
-class JavaContentGroupBuilder(val sourceSets: Set<DokkaSourceSet>) {
+class JavaContentGroupBuilder(val sourceSets: Set<ContentSourceSet>) {
val list = mutableListOf<JavadocContentNode>()
}
@@ -76,7 +75,7 @@ class TitleNode(
val parent: String?,
val dri: Set<DRI>,
val kind: Kind,
- sourceSets: Set<DokkaSourceSet>
+ sourceSets: Set<ContentSourceSet>
) : JavadocContentNode(dri, kind, sourceSets) {
override fun hasAnyContent(): Boolean = !title.isBlank() || !version.isBlank() || subtitle.isNotEmpty()
}
@@ -96,7 +95,7 @@ class RootListNode(
val entries: List<LeafListNode>,
val dri: Set<DRI>,
val kind: Kind,
- sourceSets: Set<DokkaSourceSet>,
+ sourceSets: Set<ContentSourceSet>,
) : JavadocContentNode(dri, kind, sourceSets) {
override fun hasAnyContent(): Boolean = children.isNotEmpty()
}
@@ -107,7 +106,7 @@ class LeafListNode(
val entries: List<JavadocListEntry>,
val dri: Set<DRI>,
val kind: Kind,
- sourceSets: Set<DokkaSourceSet>
+ sourceSets: Set<ContentSourceSet>
) : JavadocContentNode(dri, kind, sourceSets) {
override fun hasAnyContent(): Boolean = children.isNotEmpty()
}
@@ -142,7 +141,7 @@ class LinkJavadocListEntry(
val name: String,
val dri: Set<DRI>,
val kind: Kind = ContentKind.Symbol,
- val sourceSets: Set<DokkaSourceSet>
+ val sourceSets: Set<ContentSourceSet>
) :
JavadocListEntry {
override val stringTag: String
@@ -152,7 +151,7 @@ class LinkJavadocListEntry(
private var builtString: String? = null
- fun build(body: (String, Set<DRI>, Kind, List<DokkaSourceSet>) -> String) {
+ fun build(body: (String, Set<DRI>, Kind, List<ContentSourceSet>) -> String) {
builtString = body(name, dri, kind, sourceSets.toList())
}
}
@@ -168,6 +167,6 @@ data class JavadocSignatureContentNode(
val modifiers: ContentNode?,
val signatureWithoutModifiers: ContentNode,
val supertypes: ContentNode?
-): JavadocContentNode(setOf(dri), kind, signatureWithoutModifiers.sourceSets) {
+) : JavadocContentNode(setOf(dri), kind, signatureWithoutModifiers.sourceSets) {
override fun hasAnyContent(): Boolean = true
}
diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/KorteJavadocRenderer.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/KorteJavadocRenderer.kt
index 7826e590..4d5b9a6c 100644
--- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/KorteJavadocRenderer.kt
+++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/KorteJavadocRenderer.kt
@@ -18,8 +18,6 @@ import org.jetbrains.dokka.plugability.plugin
import org.jetbrains.dokka.plugability.querySingle
import org.jetbrains.dokka.renderers.Renderer
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
-import java.nio.file.Path
-import java.nio.file.Paths
import java.time.LocalDate
typealias TemplateMap = Map<String, Any?>
diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/SearchScriptsCreator.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/SearchScriptsCreator.kt
index 696c2e80..259e4acb 100644
--- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/SearchScriptsCreator.kt
+++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/renderer/SearchScriptsCreator.kt
@@ -7,12 +7,8 @@ import org.jetbrains.dokka.DokkaConfiguration
import org.jetbrains.dokka.base.renderers.sourceSets
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.Documentable
-import org.jetbrains.dokka.model.InheritedFunction
-import org.jetbrains.dokka.model.doc.Index
-import org.jetbrains.dokka.model.properties.WithExtraProperties
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.utilities.formatToEndWithHtml
-import org.jetbrains.dokka.utilities.htmlEscape
import java.lang.StringBuilder
class SearchScriptsCreator(private val locationProvider: JavadocLocationProvider) {
@@ -58,13 +54,23 @@ class SearchScriptsCreator(private val locationProvider: JavadocLocationProvider
}
private fun processModules(input: List<JavadocModulePageNode>): SearchData {
- val modules = SearchData(moduleRecords = input.map { SearchRecord(l = it.name, url = locationProvider.resolve(it).formatToEndWithHtml()) })
+ val modules = SearchData(moduleRecords = input.map {
+ SearchRecord(
+ l = it.name,
+ url = locationProvider.resolve(it).formatToEndWithHtml()
+ )
+ })
val processablePackages = input.flatMap { it.children.filterIsInstance<JavadocPackagePageNode>() }
return processPackages(processablePackages, modules)
}
private fun processPackages(input: List<JavadocPackagePageNode>, accumulator: SearchData): SearchData {
- val packages = input.map { SearchRecord(l = it.name, url = locationProvider.resolve(it).formatToEndWithHtml()) } + SearchRecord.allPackages
+ val packages = input.map {
+ SearchRecord(
+ l = it.name,
+ url = locationProvider.resolve(it).formatToEndWithHtml()
+ )
+ } + SearchRecord.allPackages
val types = input.flatMap {
it.children.filterIsInstance<JavadocClasslikePageNode>().map { classlike -> it to classlike }
}
@@ -148,32 +154,37 @@ class SearchScriptsCreator(private val locationProvider: JavadocLocationProvider
packageWithClasslike.second.methods.withoutInherited() +
packageWithClasslike.second.properties +
packageWithClasslike.second.entries
- ).map { it to it.indexes() }
- .flatMap { entryWithIndex ->
- entryWithIndex.second.map {
- val label = renderNode(it)
- SearchRecord(
- p = packageWithClasslike.first.name,
- c = packageWithClasslike.second.name,
- l = label,
- url = resolveUrlForSearchIndex(
- entryWithIndex.first.dri,
- packageWithClasslike.second.sourceSets(),
- label
+ ).map { it to it.indexes() }
+ .flatMap { entryWithIndex ->
+ entryWithIndex.second.map {
+ val label = renderNode(it)
+ SearchRecord(
+ p = packageWithClasslike.first.name,
+ c = packageWithClasslike.second.name,
+ l = label,
+ url = resolveUrlForSearchIndex(
+ entryWithIndex.first.dri,
+ packageWithClasslike.second.sourceSets(),
+ label
+ )
)
- )
+ }
}
- }
}
return indexesForClasslike + indexesForMemberNodes
}
- private fun <T : Documentable> WithJavadocExtra<T>.indexes(): List<ContentNode> = extra[JavadocIndexExtra]?.index.orEmpty()
+ private fun <T : Documentable> WithJavadocExtra<T>.indexes(): List<ContentNode> =
+ extra[JavadocIndexExtra]?.index.orEmpty()
private fun List<JavadocFunctionNode>.withoutInherited(): List<JavadocFunctionNode> = filter { !it.isInherited }
- private fun resolveUrlForSearchIndex(dri: DRI, sourceSets: Set<DokkaConfiguration.DokkaSourceSet>, label: String): String =
+ private fun resolveUrlForSearchIndex(
+ dri: DRI,
+ sourceSets: Set<ContentSourceSet>,
+ label: String
+ ): String =
locationProvider.resolve(dri, sourceSets).formatToEndWithHtml() + "#" + label
}
@@ -258,4 +269,4 @@ private fun renderNode(node: ContentNode): String =
when (node) {
is ContentText -> node.text
else -> node.children.joinToString(separator = "") { renderNode(it) }
- } \ No newline at end of file
+ }