blob: 2910713669df3719f9a11575f216bd1178751d1a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
package org.jetbrains.dokka.allModulesPage
import org.jetbrains.dokka.base.resolvers.local.DokkaLocationProvider
import org.jetbrains.dokka.base.resolvers.local.DokkaLocationProvider.Companion.identifierToFilename
import org.jetbrains.dokka.base.resolvers.local.LocationProvider
import org.jetbrains.dokka.base.resolvers.local.LocationProviderFactory
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.DisplaySourceSet
import org.jetbrains.dokka.pages.PageNode
import org.jetbrains.dokka.pages.RootPageNode
import org.jetbrains.dokka.plugability.DokkaContext
class MultimoduleLocationProvider(private val root: RootPageNode, context: DokkaContext) : LocationProvider {
private val defaultLocationProvider = DokkaLocationProvider(root, context)
val paths = context.configuration.modules.map {
it.name to it.relativePathToOutputDirectory
}.toMap()
override fun resolve(dri: DRI, sourceSets: Set<DisplaySourceSet>, context: PageNode?) =
dri.takeIf { it.packageName == MULTIMODULE_PACKAGE_PLACEHOLDER }?.classNames?.let { paths[it] }?.let {
"$it/${identifierToFilename(dri.classNames.orEmpty())}/index.html"
} ?: defaultLocationProvider.resolve(dri, sourceSets, context)
override fun resolve(node: PageNode, context: PageNode?, skipExtension: Boolean) =
defaultLocationProvider.resolve(node, context, skipExtension)
override fun pathToRoot(from: PageNode): String = defaultLocationProvider.pathToRoot(from)
override fun ancestors(node: PageNode): List<PageNode> = listOf(root)
companion object {
const val MULTIMODULE_PACKAGE_PLACEHOLDER = ".ext"
}
class Factory(private val context: DokkaContext): LocationProviderFactory {
override fun getLocationProvider(pageNode: RootPageNode) =
MultimoduleLocationProvider(pageNode, context)
}
}
|