From 02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33 Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Thu, 31 Aug 2023 20:16:01 +0200 Subject: Enable explicit API mode (#3139) --- .../kotlin/resolvers/local/LocationProvider.kt | 29 ++++++++++++++-------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt') diff --git a/plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt index cfabff7e..dbcd5c76 100644 --- a/plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/local/LocationProvider.kt @@ -10,11 +10,11 @@ import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.DisplaySourceSet import org.jetbrains.dokka.pages.PageNode -interface LocationProvider { - fun resolve(dri: DRI, sourceSets: Set, context: PageNode? = null): String? - fun resolve(node: PageNode, context: PageNode? = null, skipExtension: Boolean = false): String? - fun pathToRoot(from: PageNode): String - fun ancestors(node: PageNode): List +public interface LocationProvider { + public fun resolve(dri: DRI, sourceSets: Set, context: PageNode? = null): String? + public fun resolve(node: PageNode, context: PageNode? = null, skipExtension: Boolean = false): String? + public fun pathToRoot(from: PageNode): String + public fun ancestors(node: PageNode): List /** * This method should return guessed filesystem location for a given [DRI] @@ -22,17 +22,26 @@ interface LocationProvider { * generated package-list so it is ok if the path differs from the one returned by [resolve] * @return Path to a giver [DRI] or null if path should not be considered for relocations */ - fun expectedLocationForDri(dri: DRI): String = + public fun expectedLocationForDri(dri: DRI): String = (listOf(dri.packageName) + dri.classNames?.split(".")?.map { identifierToFilename(it) }.orEmpty() + listOf(dri.callable?.let { identifierToFilename(it.name) } ?: "index") ).filterNotNull().joinToString("/") } -fun LocationProvider.resolveOrThrow(dri: DRI, sourceSets: Set, context: PageNode? = null): String = - resolve(dri = dri, sourceSets = sourceSets, context = context) +public fun LocationProvider.resolveOrThrow( + dri: DRI, sourceSets: Set, + context: PageNode? = null +): String { + return resolve(dri = dri, sourceSets = sourceSets, context = context) ?: throw DokkaException("Cannot resolve path for $dri") +} -fun LocationProvider.resolveOrThrow(node: PageNode, context: PageNode? = null, skipExtension: Boolean = false): String = - resolve(node = node, context = context, skipExtension = skipExtension) +public fun LocationProvider.resolveOrThrow( + node: PageNode, + context: PageNode? = null, + skipExtension: Boolean = false +): String { + return resolve(node = node, context = context, skipExtension = skipExtension) ?: throw DokkaException("Cannot resolve path for ${node.name}") +} -- cgit