aboutsummaryrefslogtreecommitdiff
path: root/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka
diff options
context:
space:
mode:
authorBłażej Kardyś <bkardys@virtuslab.com>2020-08-27 15:38:29 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-08-27 17:09:54 +0200
commit1c6dabaee7764954a9783effa7463f9866a02066 (patch)
treeaa10f71e2e5f494962700b4dc655179375f4a8f3 /plugins/javadoc/src/main/kotlin/org/jetbrains/dokka
parent4fbb10ae5d0902fe75e4fde2e7d0a56ec45eb63f (diff)
downloaddokka-1c6dabaee7764954a9783effa7463f9866a02066.tar.gz
dokka-1c6dabaee7764954a9783effa7463f9866a02066.tar.bz2
dokka-1c6dabaee7764954a9783effa7463f9866a02066.zip
Fixing top-level functions linking for javadoc
Diffstat (limited to 'plugins/javadoc/src/main/kotlin/org/jetbrains/dokka')
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/location/JavadocLocationProvider.kt6
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt22
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt2
3 files changed, 17 insertions, 13 deletions
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 984ee0e7..38258fc6 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
@@ -49,9 +49,13 @@ class JavadocLocationProvider(pageRoot: RootPageNode, dokkaContext: DokkaContext
pageRoot.children.forEach { registerPath(it) }
}
+ private val parentPageIndex = HashMap<DRI, PageNode>()
private val nodeIndex = HashMap<DRI, PageNode>().apply {
fun registerNode(node: PageNode) {
if (node is ContentPage) put(node.dri.first(), node)
+ (node as? JavadocClasslikePageNode)?.getAnchorables()?.forEach { navigableNode ->
+ parentPageIndex[navigableNode.getDRI()] = node
+ }
node.children.forEach(::registerNode)
}
registerNode(pageRoot)
@@ -77,7 +81,7 @@ class JavadocLocationProvider(pageRoot: RootPageNode, dokkaContext: DokkaContext
private fun getLocalLocation(dri: DRI, context: PageNode?): String? =
nodeIndex[dri]?.let { resolve(it, context) }
- ?: nodeIndex[dri.parent]?.takeIf { dri.target !is PointingToGenericParameters && it is JavadocClasslikePageNode }?.let {
+ ?: parentPageIndex[dri]?.let {
val anchor = when (val anchorElement = (it as? JavadocClasslikePageNode)?.findAnchorableByDRI(dri)) {
is JavadocFunctionNode -> anchorElement.getAnchor()
is JavadocEntryNode -> anchorElement.name
diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt
index feedc493..3875c307 100644
--- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt
+++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt
@@ -1,7 +1,6 @@
package org.jetbrains.dokka.javadoc.pages
import com.intellij.psi.PsiClass
-import org.jetbrains.dokka.DokkaConfiguration
import org.jetbrains.dokka.Platform
import org.jetbrains.dokka.analysis.DescriptorDocumentableSource
import org.jetbrains.dokka.analysis.PsiDocumentableSource
@@ -15,8 +14,6 @@ import org.jetbrains.dokka.pages.*
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.resolve.DescriptorUtils.getClassDescriptorForType
-import java.util.*
-import kotlin.collections.HashMap
interface JavadocPageNode : ContentPage
@@ -25,8 +22,8 @@ interface WithJavadocExtra<T : Documentable> : WithExtraProperties<T> {
throw IllegalStateException("Merging extras is not applicable for javadoc")
}
-interface WithIndexables {
- fun getAllIndexables(): List<NavigableJavadocNode>
+interface WithNavigable {
+ fun getAllNavigables(): List<NavigableJavadocNode>
}
interface WithBrief {
@@ -73,13 +70,13 @@ class JavadocPackagePageNode(
override val children: List<PageNode> = emptyList(),
override val embeddedResources: List<String> = listOf()
) : JavadocPageNode,
- WithIndexables,
+ WithNavigable,
NavigableJavadocNode,
PackagePage {
- override fun getAllIndexables(): List<NavigableJavadocNode> =
+ override fun getAllNavigables(): List<NavigableJavadocNode> =
children.filterIsInstance<NavigableJavadocNode>().flatMap {
- if (it is WithIndexables) it.getAllIndexables()
+ if (it is WithNavigable) it.getAllNavigables()
else listOf(it)
}
@@ -185,10 +182,13 @@ class JavadocClasslikePageNode(
override val children: List<PageNode> = emptyList(),
override val embeddedResources: List<String> = listOf(),
override val extra: PropertyContainer<DClasslike> = PropertyContainer.empty(),
-) : JavadocPageNode, WithJavadocExtra<DClasslike>, NavigableJavadocNode, WithIndexables, WithBrief, ClasslikePage {
+) : JavadocPageNode, WithJavadocExtra<DClasslike>, NavigableJavadocNode, WithNavigable, WithBrief, ClasslikePage {
- override fun getAllIndexables(): List<NavigableJavadocNode> =
- methods + entries + classlikes.map { it.getAllIndexables() }.flatten() + this
+ override fun getAllNavigables(): List<NavigableJavadocNode> =
+ methods + entries + classlikes.map { it.getAllNavigables() }.flatten() + this
+
+ fun getAnchorables(): List<AnchorableJavadocNode> =
+ constructors + methods + entries + properties
val kind: String? = documentable?.kind()
val packageName = dri.first().packageName
diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt
index 5d51bc24..4b775f29 100644
--- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt
+++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt
@@ -77,7 +77,7 @@ object IndexGenerator : PageTransformer {
override fun invoke(input: RootPageNode): RootPageNode {
val elements = HashMap<Char, MutableSet<NavigableJavadocNode>>()
(input as JavadocModulePageNode).children.filterIsInstance<JavadocPackagePageNode>().forEach {
- it.getAllIndexables().forEach { d ->
+ it.getAllNavigables().forEach { d ->
val name = when (d) {
is JavadocPageNode -> d.name
is AnchorableJavadocNode -> d.name