aboutsummaryrefslogtreecommitdiff
path: root/plugins/all-modules-page/src/main/kotlin/MultimoduleLocationProvider.kt
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2021-01-21 00:34:43 +0100
committerGitHub <noreply@github.com>2021-01-21 00:34:43 +0100
commitfdf8a298f586d7e334c312346b70b59c64c8d037 (patch)
treed9e92e920c24f442df6339e19b27225d7d01d21b /plugins/all-modules-page/src/main/kotlin/MultimoduleLocationProvider.kt
parent1f592a7ec2786e0a0b77d224d1414ef3042caae4 (diff)
downloaddokka-fdf8a298f586d7e334c312346b70b59c64c8d037.tar.gz
dokka-fdf8a298f586d7e334c312346b70b59c64c8d037.tar.bz2
dokka-fdf8a298f586d7e334c312346b70b59c64c8d037.zip
Empty modules filtering (#1699)
Diffstat (limited to 'plugins/all-modules-page/src/main/kotlin/MultimoduleLocationProvider.kt')
-rw-r--r--plugins/all-modules-page/src/main/kotlin/MultimoduleLocationProvider.kt22
1 files changed, 14 insertions, 8 deletions
diff --git a/plugins/all-modules-page/src/main/kotlin/MultimoduleLocationProvider.kt b/plugins/all-modules-page/src/main/kotlin/MultimoduleLocationProvider.kt
index c7c32d55..1a323f63 100644
--- a/plugins/all-modules-page/src/main/kotlin/MultimoduleLocationProvider.kt
+++ b/plugins/all-modules-page/src/main/kotlin/MultimoduleLocationProvider.kt
@@ -5,24 +5,30 @@ import org.jetbrains.dokka.base.resolvers.local.DokkaBaseLocationProvider
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.ContentPage
import org.jetbrains.dokka.pages.PageNode
import org.jetbrains.dokka.pages.RootPageNode
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.plugability.plugin
import org.jetbrains.dokka.plugability.querySingle
-open class MultimoduleLocationProvider(private val root: RootPageNode, dokkaContext: DokkaContext) : DokkaBaseLocationProvider(root, dokkaContext) {
+open class MultimoduleLocationProvider(private val root: RootPageNode, dokkaContext: DokkaContext) :
+ DokkaBaseLocationProvider(root, dokkaContext) {
- private val defaultLocationProvider = dokkaContext.plugin<AllModulesPagePlugin>().querySingle { partialLocationProviderFactory }.getLocationProvider(root)
- private val externalModuleLinkResolver = dokkaContext.plugin<AllModulesPagePlugin>().querySingle { externalModuleLinkResolver }
+ private val defaultLocationProvider =
+ dokkaContext.plugin<AllModulesPagePlugin>().querySingle { partialLocationProviderFactory }
+ .getLocationProvider(root)
+ private val externalModuleLinkResolver =
+ dokkaContext.plugin<AllModulesPagePlugin>().querySingle { externalModuleLinkResolver }
override fun resolve(dri: DRI, sourceSets: Set<DisplaySourceSet>, context: PageNode?) =
- if (dri == MultimodulePageCreator.MULTIMODULE_ROOT_DRI) pathToRoot(root)
- else dri.takeIf { it.packageName == MULTIMODULE_PACKAGE_PLACEHOLDER }?.classNames
- ?.let(externalModuleLinkResolver::resolveLinkToModuleIndex)
+ if (dri == MultimodulePageCreator.MULTIMODULE_ROOT_DRI) pathToRoot(root) + "index"
+ else dri.takeIf { it.packageName == MULTIMODULE_PACKAGE_PLACEHOLDER }?.classNames
+ ?.let(externalModuleLinkResolver::resolveLinkToModuleIndex)
override fun resolve(node: PageNode, context: PageNode?, skipExtension: Boolean) =
- defaultLocationProvider.resolve(node, context, skipExtension)
+ if (node is ContentPage && MultimodulePageCreator.MULTIMODULE_ROOT_DRI in node.dri) pathToRoot(root) + "index"
+ else defaultLocationProvider.resolve(node, context, skipExtension)
override fun pathToRoot(from: PageNode): String = defaultLocationProvider.pathToRoot(from)
@@ -30,6 +36,6 @@ open class MultimoduleLocationProvider(private val root: RootPageNode, dokkaCont
class Factory(private val context: DokkaContext) : LocationProviderFactory {
override fun getLocationProvider(pageNode: RootPageNode) =
- MultimoduleLocationProvider(pageNode, context)
+ MultimoduleLocationProvider(pageNode, context)
}
}