From f6ac2b0f0a0183171aa2f6806ec67d8d21692a36 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Thu, 13 Aug 2020 09:59:39 +0200 Subject: Implement `ContentSourceSet` --- .../jetbrains/dokka/javadoc/JavadocPageCreator.kt | 15 +++--- .../javadoc/location/JavadocLocationProvider.kt | 4 +- .../dokka/javadoc/pages/JavadocContentNodes.kt | 23 +++++---- .../dokka/javadoc/renderer/KorteJavadocRenderer.kt | 2 - .../dokka/javadoc/renderer/SearchScriptsCreator.kt | 57 +++++++++++++--------- 5 files changed, 55 insertions(+), 46 deletions(-) (limited to 'plugins/javadoc/src/main/kotlin') 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.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.nodeForJvm(jvm: DokkaSourceSet): ContentNode = - first { it.sourceSets.contains(jvm) } + first { jvm.sourceSetID in it.sourceSets.sourceSetIDs } private fun Documentable.brief(sourceSet: DokkaSourceSet? = highestJvmSourceSet): List = 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()?.toList().orEmpty() + val indexes = + documentation[highestJvmSourceSet]?.withDescendants()?.filterIsInstance()?.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, context: PageNode?): String { + override fun resolve(dri: DRI, sourceSets: Set, 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, kind: Kind, - override val sourceSets: Set + override val sourceSets: Set ) : ContentNode { override val dci: DCI = DCI(dri, kind) override val style: Set