From 64e600b126ae8edcfbb3c2716febb01d221520b5 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Tue, 14 Apr 2020 14:14:31 +0200 Subject: Fix path clash with top-level declarations, catch link resolving exception, remove default values while merging, merge expect by targets --- .../documentables/DefaultDocumentableMerger.kt | 3 ++- .../ModuleAndPackageDocumentationTransformer.kt | 17 +++++++++++------ .../DefaultDescriptorToDocumentableTranslator.kt | 4 +++- 3 files changed, 16 insertions(+), 8 deletions(-) (limited to 'plugins/base/src/main/kotlin') diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt index 23a67804..4daa4a50 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt @@ -60,7 +60,8 @@ private fun mergeExpectActual( ): List where T : Documentable, T : WithExpectActual { fun findExpect(actual: T, expects: List): Expect = - expects.find { it.platformData.containsAll(actual.platformData) }.let { Expect.from(it) } + expects.find { it.platformData.flatMap { it.targets }.containsAll(actual.platformData.flatMap { it.targets }) } + .let { Expect.from(it) } fun reduceExpectActual(entry: Map.Entry, List>): List = when (val expect = entry.key) { Expect.NotFound -> entry.value diff --git a/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt index 50246e5a..a5d6540e 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationTransformer.kt @@ -52,12 +52,17 @@ internal object ModuleAndPackageDocumentationTransformer : PreMergeDocumentableT val doc = modulesAndPackagesDocumentation[Pair(module.name, pd)] val facade = context.platforms[pd]?.facade ?: return@mapNotNull null.also { context.logger.warn("Could not find platform data for ${pd.name}") } - doc?.get("Module")?.get(module.name)?.run { - pd to MarkdownParser( - facade, - facade.moduleDescriptor, - context.logger - ).parse(this) + try { + doc?.get("Module")?.get(module.name)?.run { + pd to MarkdownParser( + facade, + facade.moduleDescriptor, + context.logger + ).parse(this) + } + } catch (e: IllegalArgumentException) { + context.logger.error(e.message.orEmpty()) + null } }.toMap() diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index 0e24fc08..c2f190c2 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -72,7 +72,9 @@ private class DokkaDescriptorVisitor( descriptor: PackageFragmentDescriptor, parent: DRIWithPlatformInfo ): DPackage { - val driWithPlatform = DRI(packageName = descriptor.fqName.asString()).withEmptyInfo() + val name = descriptor.fqName.asString().takeUnless { it.isBlank() } ?: + "<" + platformData.targets.joinToString(",") + " root>"// TODO: error-prone, find a better way to do it + val driWithPlatform = DRI(packageName = name).withEmptyInfo() val scope = descriptor.getMemberScope() return DPackage( -- cgit