diff options
author | Andrzej Ratajczak <andrzej.ratajczak98@gmail.com> | 2020-06-25 14:22:51 +0200 |
---|---|---|
committer | Andrzej Ratajczak <32793002+BarkingBad@users.noreply.github.com> | 2020-09-08 12:52:59 +0200 |
commit | a1f8efc30b4421ce371b02b747bbeac24fafd7ba (patch) | |
tree | 7dba1baab9ad4d8db7436e65c7e9c26618a07c89 /plugins/base/src/main/kotlin/resolvers | |
parent | 270ff58ea44b7700be45062f75bbc7fd50d183eb (diff) | |
download | dokka-a1f8efc30b4421ce371b02b747bbeac24fafd7ba.tar.gz dokka-a1f8efc30b4421ce371b02b747bbeac24fafd7ba.tar.bz2 dokka-a1f8efc30b4421ce371b02b747bbeac24fafd7ba.zip |
Changed way of merging documentables to avoid exception on merging documentables of different types. Minor javadoc fixes. Changed constructor names. Add handling same name pages clash for different platforms
Diffstat (limited to 'plugins/base/src/main/kotlin/resolvers')
-rw-r--r-- | plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt | 1 | ||||
-rw-r--r-- | plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt | 40 |
2 files changed, 27 insertions, 14 deletions
diff --git a/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt index c25aa543..e085af1a 100644 --- a/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt @@ -4,6 +4,7 @@ import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.resolvers.external.ExternalLocationProvider import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation import org.jetbrains.dokka.base.resolvers.shared.PackageList +import org.jetbrains.dokka.base.resolvers.anchors.SymbolAnchorHint import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.DisplaySourceSet import org.jetbrains.dokka.pages.RootPageNode diff --git a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt index 096104cc..0269d7a6 100644 --- a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt @@ -1,5 +1,6 @@ package org.jetbrains.dokka.base.resolvers.local +import org.jetbrains.dokka.base.renderers.sourceSets import org.jetbrains.dokka.base.resolvers.anchors.SymbolAnchorHint import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.links.PointingToDeclaration @@ -26,35 +27,46 @@ open class DokkaLocationProvider( pageGraphRoot.children.forEach { registerPath(it, emptyList()) } } - protected open val pagesIndex: Map<DRI, ContentPage> = + protected val pagesIndex: Map<Pair<DRI, DisplaySourceSet>, ContentPage> = pageGraphRoot.withDescendants().filterIsInstance<ContentPage>() - .flatMap { it.dri.map { dri -> dri to it } } + .flatMap { page -> + page.dri.flatMap { dri -> + page.sourceSets().map { sourceSet -> (dri to sourceSet) to page } + } + } .groupingBy { it.first } - .aggregate { dri, _, (_, page), first -> - if (first) page else throw AssertionError("Multiple pages associated with dri: $dri") + .aggregate { key, _, (_, page), first -> + if (first) page else throw AssertionError("Multiple pages associated with key: ${key.first}/${key.second}") } - protected open val anchorsIndex: Map<DRI, ContentPage> = + protected val anchorsIndex: Map<Pair<DRI, DisplaySourceSet>, ContentPage> = pageGraphRoot.withDescendants().filterIsInstance<ContentPage>() .flatMap { page -> page.content.withDescendants() .filter { it.extra[SymbolAnchorHint] != null } .mapNotNull { it.dci.dri.singleOrNull() } .distinct() - .map { it to page } + .flatMap { dri -> + page.sourceSets().map { sourceSet -> + (dri to sourceSet) to page + } + } }.toMap() override fun resolve(node: PageNode, context: PageNode?, skipExtension: Boolean) = pathTo(node, context) + if (!skipExtension) extension else "" - override fun resolve(dri: DRI, sourceSets: Set<DisplaySourceSet>, context: PageNode?) = - getLocalLocation(dri, context) - ?: getLocalLocation(dri.copy(target = PointingToDeclaration), context) - // Not found in PageGraph, that means it's an external link - ?: getExternalLocation(dri, sourceSets) - ?: getExternalLocation(dri.copy(target = PointingToDeclaration), sourceSets) - - private fun getLocalLocation(dri: DRI, context: PageNode?): String? = + override fun resolve(dri: DRI, sourceSets: Set<DisplaySourceSet>, context: PageNode?): String? = + sourceSets.mapNotNull { sourceSet -> + val driWithSourceSet = Pair(dri, sourceSet) + getLocalLocation(driWithSourceSet, context) + ?: getLocalLocation(driWithSourceSet.copy(first = dri.copy(target = PointingToDeclaration)), context) + // Not found in PageGraph, that means it's an external link + ?: getExternalLocation(dri, sourceSets) + ?: getExternalLocation(dri.copy(target = PointingToDeclaration), sourceSets) + }.distinct().singleOrNull() + + private fun getLocalLocation(dri: Pair<DRI, DisplaySourceSet>, context: PageNode?): String? = pagesIndex[dri]?.let { resolve(it, context) } ?: anchorsIndex[dri]?.let { resolve(it, context) + "#$dri" } |