aboutsummaryrefslogtreecommitdiff
path: root/plugins/javadoc/src/main/kotlin/org
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-08-13 09:59:39 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-08-17 11:52:28 +0200
commitf6ac2b0f0a0183171aa2f6806ec67d8d21692a36 (patch)
treea912d7ba4d7d368b9a3683a6cf290ca135ee231a /plugins/javadoc/src/main/kotlin/org
parent86fcfb73d2d5124ae7748a80db29bdbb68607be4 (diff)
downloaddokka-f6ac2b0f0a0183171aa2f6806ec67d8d21692a36.tar.gz
dokka-f6ac2b0f0a0183171aa2f6806ec67d8d21692a36.tar.bz2
dokka-f6ac2b0f0a0183171aa2f6806ec67d8d21692a36.zip
Implement `ContentSourceSet`
Diffstat (limited to 'plugins/javadoc/src/main/kotlin/org')
-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
5 files changed, 55 insertions, 46 deletions
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
+ }