From a4053154631c08bd91fdb1dd098265e301d76a02 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Tue, 5 Nov 2019 18:40:47 +0100 Subject: Fix external link resolution --- .../main/kotlin/resolvers/DefaultLocationProvider.kt | 4 ++-- .../main/kotlin/resolvers/ExternalLocationProvider.kt | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'core') diff --git a/core/src/main/kotlin/resolvers/DefaultLocationProvider.kt b/core/src/main/kotlin/resolvers/DefaultLocationProvider.kt index f8faa45b..669b720e 100644 --- a/core/src/main/kotlin/resolvers/DefaultLocationProvider.kt +++ b/core/src/main/kotlin/resolvers/DefaultLocationProvider.kt @@ -13,8 +13,8 @@ open class DefaultLocationProvider(private val pageGraphRoot: PageNode, val conf // Not found in PageGraph, that means it's an external link ExternalLocationProvider.getLocation(dri, configuration.passesConfigurations - .filter { passConfig -> passConfig.targets.toSet() == platforms.toSet() } // TODO: change targets to something better? - .flatMap { it.externalDocumentationLinks }.map { it.packageListUrl }.distinct() + .filter { passConfig -> passConfig.targets.map { PlatformData(it, passConfig.analysisPlatform)}.toSet() == platforms.toSet() } // TODO: change targets to something better? + .flatMap { it.externalDocumentationLinks }.distinct() ) override fun resolveRoot(node: PageNode): String = "../${pathTo(pageGraphRoot, node).removeSuffix( diff --git a/core/src/main/kotlin/resolvers/ExternalLocationProvider.kt b/core/src/main/kotlin/resolvers/ExternalLocationProvider.kt index e9181148..d3d8fa0d 100644 --- a/core/src/main/kotlin/resolvers/ExternalLocationProvider.kt +++ b/core/src/main/kotlin/resolvers/ExternalLocationProvider.kt @@ -1,5 +1,6 @@ package org.jetbrains.dokka.resolvers +import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink import org.jetbrains.dokka.links.DRI import java.net.HttpURLConnection import java.net.URL @@ -10,22 +11,22 @@ object ExternalLocationProvider { // TODO: Refactor this!!! private val cache: MutableMap = mutableMapOf() - fun getLocation(dri: DRI, packageLocations: List): String { - val toResolve: MutableList = mutableListOf() - for(url in packageLocations){ - val info = cache[url] + fun getLocation(dri: DRI, externalDocumentationLinks: List): String { + val toResolve: MutableList = mutableListOf() + for(link in externalDocumentationLinks){ + val info = cache[link.packageListUrl] if(info == null) { - toResolve.add(url) + toResolve.add(link) } else if(info.packages.contains(dri.packageName)) { - return getLink(dri, info) + return link.url.toExternalForm() + getLink(dri, info) } } // Not in cache, resolve packageLists while (toResolve.isNotEmpty()){ - val loc = toResolve.first().also { toResolve.remove(it) } - val locationInfo = loadPackageList(loc) + val link = toResolve.first().also { toResolve.remove(it) } + val locationInfo = loadPackageList(link.packageListUrl) if(locationInfo.packages.contains(dri.packageName)) { - return getLink(dri, locationInfo) + return link.url.toExternalForm() + getLink(dri, locationInfo) } } return "" -- cgit