diff options
author | Kamil Doległo <kamilok1965@interia.pl> | 2019-11-05 18:40:47 +0100 |
---|---|---|
committer | Kamil Doległo <kamilok1965@interia.pl> | 2019-11-05 18:40:47 +0100 |
commit | a4053154631c08bd91fdb1dd098265e301d76a02 (patch) | |
tree | d4cbdafb643d3382d80dbf43206ffbea3d4efd71 /core | |
parent | 00b314f12a05e3bbda805d0ae49c34f5542298b4 (diff) | |
download | dokka-a4053154631c08bd91fdb1dd098265e301d76a02.tar.gz dokka-a4053154631c08bd91fdb1dd098265e301d76a02.tar.bz2 dokka-a4053154631c08bd91fdb1dd098265e301d76a02.zip |
Fix external link resolution
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/kotlin/resolvers/DefaultLocationProvider.kt | 4 | ||||
-rw-r--r-- | core/src/main/kotlin/resolvers/ExternalLocationProvider.kt | 19 |
2 files changed, 12 insertions, 11 deletions
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<URL, LocationInfo> = mutableMapOf() - fun getLocation(dri: DRI, packageLocations: List<URL>): String { - val toResolve: MutableList<URL> = mutableListOf() - for(url in packageLocations){ - val info = cache[url] + fun getLocation(dri: DRI, externalDocumentationLinks: List<ExternalDocumentationLink>): String { + val toResolve: MutableList<ExternalDocumentationLink> = 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 "" |