Skip to content

Commit

Permalink
Fix not escaping module name in DefaultExternalModuleLinkResolver (#1777
Browse files Browse the repository at this point in the history
)
  • Loading branch information
kamildoleglo authored Mar 15, 2021
1 parent f5c791a commit 301ee38
Showing 1 changed file with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,26 @@ class DefaultExternalModuleLinkResolver(val context: DokkaContext) : ExternalMod
elpFactory.flatMap { externalDocumentations.map { ed -> it.getExternalLocationProvider(ed) } }.filterNotNull()
}

private fun setupExternalDocumentations(): List<ExternalDocumentation> {
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<ExternalDocumentation> =
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
}

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
Expand All @@ -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,
Expand Down

0 comments on commit 301ee38

Please sign in to comment.