diff options
author | Marcin Aman <marcin.aman@gmail.com> | 2021-03-04 17:23:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-04 17:23:30 +0100 |
commit | ac2c1adf18289acbff8a79e8cbabe58e00f30f63 (patch) | |
tree | 89f206d16df7860095c7547346a4f15fb769d0fd /plugins/base/src/main/kotlin/resolvers | |
parent | b298da4ce1a55a6f69e7ed00020ed3af558f3750 (diff) | |
download | dokka-ac2c1adf18289acbff8a79e8cbabe58e00f30f63.tar.gz dokka-ac2c1adf18289acbff8a79e8cbabe58e00f30f63.tar.bz2 dokka-ac2c1adf18289acbff8a79e8cbabe58e00f30f63.zip |
Fix clashing properties and external links ordering (#1765)
Diffstat (limited to 'plugins/base/src/main/kotlin/resolvers')
-rw-r--r-- | plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt index c956b308..87683414 100644 --- a/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt @@ -1,7 +1,11 @@ package org.jetbrains.dokka.base.resolvers.local import org.jetbrains.dokka.base.DokkaBase +import org.jetbrains.dokka.base.resolvers.external.DefaultExternalLocationProvider +import org.jetbrains.dokka.base.resolvers.external.Dokka010ExternalLocationProvider import org.jetbrains.dokka.base.resolvers.external.ExternalLocationProvider +import org.jetbrains.dokka.base.resolvers.external.javadoc.AndroidExternalLocationProvider +import org.jetbrains.dokka.base.resolvers.external.javadoc.JavadocExternalLocationProvider import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation import org.jetbrains.dokka.base.resolvers.shared.PackageList import org.jetbrains.dokka.links.DRI @@ -36,12 +40,16 @@ abstract class DefaultLocationProvider( } .toMap() - protected val packagesIndex: Map<String, ExternalLocationProvider?> = externalLocationProviders - .flatMap { (extDocInfo, externalLocationProvider) -> - extDocInfo.packageList.packages.map { packageName -> packageName to externalLocationProvider } - } - .toMap() - .filterKeys(String::isNotBlank) + protected val packagesIndex: Map<String, ExternalLocationProvider?> = + externalLocationProviders + .flatMap { (extDocInfo, externalLocationProvider) -> + extDocInfo.packageList.packages.map { packageName -> packageName to externalLocationProvider } + }.groupBy { it.first }.mapValues { (_, lst) -> + lst.map { it.second } + .sortedWith(compareBy(nullsLast(ExternalLocationProviderOrdering)) { it }) + .firstOrNull() + } + .filterKeys(String::isNotBlank) protected val locationsIndex: Map<String, ExternalLocationProvider?> = externalLocationProviders @@ -56,4 +64,16 @@ abstract class DefaultLocationProvider( ?: locationsIndex[dri.toString()]?.resolve(dri) ?: externalLocationProviders.values.mapNotNull { it?.resolve(dri) }.firstOrNull() + private object ExternalLocationProviderOrdering : Comparator<ExternalLocationProvider> { + private val desiredOrdering = listOf( + DefaultExternalLocationProvider::class, + Dokka010ExternalLocationProvider::class, + AndroidExternalLocationProvider::class, + JavadocExternalLocationProvider::class + ) + + override fun compare(o1: ExternalLocationProvider, o2: ExternalLocationProvider): Int = + desiredOrdering.indexOf(o1::class).compareTo(desiredOrdering.indexOf(o2::class)) + } + } |