From 0dae23995d23fadb9c1148d4120d01f856d7fa4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Doleg=C5=82o?= Date: Mon, 15 Mar 2021 13:49:19 +0100 Subject: [PATCH] Fix not escaping module name in DefaultExternalModuleLinkResolver --- .../main/kotlin/ExternalModuleLinkResolver.kt | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/plugins/all-modules-page/src/main/kotlin/ExternalModuleLinkResolver.kt b/plugins/all-modules-page/src/main/kotlin/ExternalModuleLinkResolver.kt index 74513957d5..0fde629c75 100644 --- a/plugins/all-modules-page/src/main/kotlin/ExternalModuleLinkResolver.kt +++ b/plugins/all-modules-page/src/main/kotlin/ExternalModuleLinkResolver.kt @@ -25,22 +25,18 @@ class DefaultExternalModuleLinkResolver(val context: DokkaContext) : ExternalMod elpFactory.flatMap { externalDocumentations.map { ed -> it.getExternalLocationProvider(ed) } }.filterNotNull() } - private fun setupExternalDocumentations(): List { - val packageLists = - context.configuration.modules.map(::loadPackageListForModule).toMap() - return packageLists.mapNotNull { (module, packageList) -> - packageList?.let { - context.configuration.modules.find { it.name == module.name }?.let { m -> - ExternalDocumentation( - URL("file:/${m.relativePathToOutputDirectory.toRelativeOutputDir()}"), - packageList - ) - } + private fun setupExternalDocumentations(): List = + context.configuration.modules.mapNotNull { module -> + loadPackageListForModule(module)?.let { packageList -> + ExternalDocumentation( + URL("file:/${module.relativePathToOutputDirectory.toRelativeOutputDir()}"), + packageList + ) } } - } - private fun File.toRelativeOutputDir(): File = if(isAbsolute) { + + private fun File.toRelativeOutputDir(): File = if (isAbsolute) { relativeToOrSelf(context.configuration.outputDir) } else { this @@ -48,7 +44,7 @@ class DefaultExternalModuleLinkResolver(val context: DokkaContext) : ExternalMod private fun loadPackageListForModule(module: DokkaConfiguration.DokkaModuleDescription) = module.sourceOutputDirectory.resolve(File(identifierToFilename(module.name))).let { - it to PackageList.load( + PackageList.load( URL("file:" + it.resolve("package-list").path), 8, true @@ -70,7 +66,7 @@ class DefaultExternalModuleLinkResolver(val context: DokkaContext) : ExternalMod override fun resolveLinkToModuleIndex(moduleName: String): String? = context.configuration.modules.firstOrNull { it.name == moduleName } ?.let { module -> - val (_, packageList) = loadPackageListForModule(module) + val packageList = loadPackageListForModule(module) val extension = when (packageList?.linkFormat) { RecognizedLinkFormat.KotlinWebsiteHtml, RecognizedLinkFormat.DokkaOldHtml,