From 1c0be46a1d40c8c706486b5488e5897f1e7ab610 Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Tue, 1 Sep 2020 15:35:32 +0200 Subject: Fix multimodule DRI location provider mapping --- .../src/main/kotlin/resolvers/local/DokkaLocationProvider.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'plugins/base/src/main/kotlin/resolvers/local') diff --git a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt index 0269d7a6..14111a3b 100644 --- a/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/local/DokkaLocationProvider.kt @@ -27,11 +27,11 @@ open class DokkaLocationProvider( pageGraphRoot.children.forEach { registerPath(it, emptyList()) } } - protected val pagesIndex: Map, ContentPage> = + protected val pagesIndex: Map, ContentPage> = pageGraphRoot.withDescendants().filterIsInstance() .flatMap { page -> page.dri.flatMap { dri -> - page.sourceSets().map { sourceSet -> (dri to sourceSet) to page } + page.sourceSets().ifEmpty { setOf(null) }.map { sourceSet -> (dri to sourceSet) to page } } } .groupingBy { it.first } @@ -39,7 +39,7 @@ open class DokkaLocationProvider( if (first) page else throw AssertionError("Multiple pages associated with key: ${key.first}/${key.second}") } - protected val anchorsIndex: Map, ContentPage> = + protected val anchorsIndex: Map, ContentPage> = pageGraphRoot.withDescendants().filterIsInstance() .flatMap { page -> page.content.withDescendants() @@ -47,7 +47,7 @@ open class DokkaLocationProvider( .mapNotNull { it.dci.dri.singleOrNull() } .distinct() .flatMap { dri -> - page.sourceSets().map { sourceSet -> + page.sourceSets().ifEmpty { setOf(null) }.map { sourceSet -> (dri to sourceSet) to page } } @@ -57,7 +57,7 @@ open class DokkaLocationProvider( pathTo(node, context) + if (!skipExtension) extension else "" override fun resolve(dri: DRI, sourceSets: Set, context: PageNode?): String? = - sourceSets.mapNotNull { sourceSet -> + sourceSets.ifEmpty { setOf(null) }.mapNotNull { sourceSet -> val driWithSourceSet = Pair(dri, sourceSet) getLocalLocation(driWithSourceSet, context) ?: getLocalLocation(driWithSourceSet.copy(first = dri.copy(target = PointingToDeclaration)), context) @@ -66,7 +66,7 @@ open class DokkaLocationProvider( ?: getExternalLocation(dri.copy(target = PointingToDeclaration), sourceSets) }.distinct().singleOrNull() - private fun getLocalLocation(dri: Pair, context: PageNode?): String? = + private fun getLocalLocation(dri: Pair, context: PageNode?): String? = pagesIndex[dri]?.let { resolve(it, context) } ?: anchorsIndex[dri]?.let { resolve(it, context) + "#$dri" } -- cgit