aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProvider.kt
diff options
context:
space:
mode:
authorKamil Doległo <kamilok1965@interia.pl>2020-08-11 21:47:26 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-08-19 13:34:10 +0200
commit852a6ce6c0f43c9b2044320dcceb4c6cc0a3b302 (patch)
treefb95be79e816769ca5305cf3a601348549000c6d /plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProvider.kt
parent822653f017fa58352148e1c586690debb6773965 (diff)
downloaddokka-852a6ce6c0f43c9b2044320dcceb4c6cc0a3b302.tar.gz
dokka-852a6ce6c0f43c9b2044320dcceb4c6cc0a3b302.tar.bz2
dokka-852a6ce6c0f43c9b2044320dcceb4c6cc0a3b302.zip
Refactor location providers
Diffstat (limited to 'plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProvider.kt')
-rw-r--r--plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProvider.kt22
1 files changed, 22 insertions, 0 deletions
diff --git a/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProvider.kt
new file mode 100644
index 00000000..5e22206b
--- /dev/null
+++ b/plugins/base/src/main/kotlin/resolvers/external/DefaultExternalLocationProvider.kt
@@ -0,0 +1,22 @@
+package org.jetbrains.dokka.base.resolvers.external
+
+import org.jetbrains.dokka.base.resolvers.local.DokkaLocationProvider.Companion.identifierToFilename
+import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentationInfo
+import org.jetbrains.dokka.links.DRI
+import org.jetbrains.dokka.plugability.DokkaContext
+
+open class DefaultExternalLocationProvider(
+ val externalDocumentationInfo: ExternalDocumentationInfo,
+ val extension: String,
+ val dokkaContext: DokkaContext
+) : ExternalLocationProvider {
+ override fun resolve(dri: DRI): String? { // TODO: classes without packages?
+ val docURL = externalDocumentationInfo.documentationURL.toString().removeSuffix("/") + "/"
+ val classNamesChecked = dri.classNames ?: return "$docURL${dri.packageName ?: ""}/index$extension"
+ val classLink = (listOfNotNull(dri.packageName) + classNamesChecked.split('.'))
+ .joinToString("/", transform = ::identifierToFilename)
+
+ val callableChecked = dri.callable ?: return "$docURL$classLink/index$extension"
+ return "$docURL$classLink/" + identifierToFilename(callableChecked.name) + extension
+ }
+}