diff options
Diffstat (limited to 'plugins/base/src/main/kotlin')
8 files changed, 43 insertions, 34 deletions
diff --git a/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt b/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt index d1832cbc..a87d4319 100644 --- a/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt +++ b/plugins/base/src/main/kotlin/allModulePage/MultimodulePageCreator.kt @@ -16,7 +16,6 @@ import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.querySingle import org.jetbrains.dokka.transformers.pages.PageCreator import org.jetbrains.dokka.utilities.DokkaLogger -import java.io.File class MultimodulePageCreator( val context: DokkaContext diff --git a/plugins/base/src/main/kotlin/parsers/moduleAndPackage/parseModuleAndPackageDocumentationFragments.kt b/plugins/base/src/main/kotlin/parsers/moduleAndPackage/parseModuleAndPackageDocumentationFragments.kt index 6155af52..e66b7612 100644 --- a/plugins/base/src/main/kotlin/parsers/moduleAndPackage/parseModuleAndPackageDocumentationFragments.kt +++ b/plugins/base/src/main/kotlin/parsers/moduleAndPackage/parseModuleAndPackageDocumentationFragments.kt @@ -37,9 +37,9 @@ private fun parseModuleAndPackageDocFragment( } val name = classifierAndName.getOrNull(1)?.trim().orEmpty() - if (name.contains(Regex("\\s"))) { + if (classifier == Package && name.contains(Regex("\\s"))) { throw IllegalModuleAndPackageDocumentation( - source, "Module/Package name cannot contain whitespace in '$firstLine'" + source, "Package name cannot contain whitespace in '$firstLine'" ) } diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt index c8e4f565..17ead667 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt @@ -10,20 +10,15 @@ internal object DefaultDocumentableMerger : DocumentableMerger { override fun invoke(modules: Collection<DModule>, context: DokkaContext): DModule { - val projectName = - modules.fold(modules.first().name) { acc, module -> acc.commonPrefixWith(module.name) } - .takeIf { it.isNotEmpty() } - ?: "project" - return modules.reduce { left, right -> val list = listOf(left, right) DModule( - name = projectName, + name = modules.map { it.name }.distinct().joinToString("|"), packages = merge( list.flatMap { it.packages }, DPackage::mergeWith ), - documentation = list.map { it.documentation }.flatMap { it.entries }.associate { (k,v) -> k to v }, + documentation = list.map { it.documentation }.flatMap { it.entries }.associate { (k, v) -> k to v }, expectPresentInSet = list.firstNotNullResult { it.expectPresentInSet }, sourceSets = list.flatMap { it.sourceSets }.toSet() ).mergeExtras(left, right) @@ -61,7 +56,7 @@ fun DFunction.mergeWith(other: DFunction): DFunction = copy( receiver = receiver?.let { r -> other.receiver?.let { r.mergeWith(it) } ?: r } ?: other.receiver, documentation = documentation + other.documentation, expectPresentInSet = expectPresentInSet ?: other.expectPresentInSet, - sources = sources+ other.sources, + sources = sources + other.sources, visibility = visibility + other.visibility, modifier = modifier + other.modifier, sourceSets = sourceSets + other.sourceSets, @@ -72,7 +67,7 @@ fun DProperty.mergeWith(other: DProperty): DProperty = copy( receiver = receiver?.let { r -> other.receiver?.let { r.mergeWith(it) } ?: r } ?: other.receiver, documentation = documentation + other.documentation, expectPresentInSet = expectPresentInSet ?: other.expectPresentInSet, - sources = sources+ other.sources, + sources = sources + other.sources, visibility = visibility + other.visibility, modifier = modifier + other.modifier, sourceSets = sourceSets + other.sourceSets, @@ -104,7 +99,7 @@ fun DClass.mergeWith(other: DClass): DClass = copy( supertypes = supertypes + other.supertypes, documentation = documentation + other.documentation, expectPresentInSet = expectPresentInSet ?: other.expectPresentInSet, - sources = sources+ other.sources, + sources = sources + other.sources, visibility = visibility + other.visibility, sourceSets = sourceSets + other.sourceSets ).mergeExtras(this, other) @@ -122,7 +117,7 @@ fun DEnum.mergeWith(other: DEnum): DEnum = copy( supertypes = supertypes + other.supertypes, documentation = documentation + other.documentation, expectPresentInSet = expectPresentInSet ?: other.expectPresentInSet, - sources = sources+ other.sources, + sources = sources + other.sources, visibility = visibility + other.visibility, sourceSets = sourceSets + other.sourceSets ).mergeExtras(this, other) @@ -143,7 +138,7 @@ fun DObject.mergeWith(other: DObject): DObject = copy( supertypes = supertypes + other.supertypes, documentation = documentation + other.documentation, expectPresentInSet = expectPresentInSet ?: other.expectPresentInSet, - sources = sources+ other.sources, + sources = sources + other.sources, visibility = visibility + other.visibility, sourceSets = sourceSets + other.sourceSets ).mergeExtras(this, other) @@ -157,7 +152,7 @@ fun DInterface.mergeWith(other: DInterface): DInterface = copy( supertypes = supertypes + other.supertypes, documentation = documentation + other.documentation, expectPresentInSet = expectPresentInSet ?: other.expectPresentInSet, - sources = sources+ other.sources, + sources = sources + other.sources, visibility = visibility + other.visibility, sourceSets = sourceSets + other.sourceSets ).mergeExtras(this, other) @@ -173,7 +168,7 @@ fun DAnnotation.mergeWith(other: DAnnotation): DAnnotation = copy( companion = companion?.let { c -> other.companion?.let { c.mergeWith(it) } ?: c } ?: other.companion, documentation = documentation + other.documentation, expectPresentInSet = expectPresentInSet ?: other.expectPresentInSet, - sources = sources+ other.sources, + sources = sources + other.sources, visibility = visibility + other.visibility, sourceSets = sourceSets + other.sourceSets, generics = merge(generics + other.generics, DTypeParameter::mergeWith) @@ -197,4 +192,4 @@ fun DTypeAlias.mergeWith(other: DTypeAlias): DTypeAlias = copy( underlyingType = underlyingType + other.underlyingType, visibility = visibility + other.visibility, sourceSets = sourceSets + other.sourceSets -).mergeExtras(this, other)
\ No newline at end of file +).mergeExtras(this, other) diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DeprecatedDocumentableFilterTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/DeprecatedDocumentableFilterTransformer.kt index 66156832..6a6231c5 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DeprecatedDocumentableFilterTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DeprecatedDocumentableFilterTransformer.kt @@ -249,4 +249,4 @@ class DeprecatedDocumentableFilterTransformer(val context: DokkaContext) : PreMe } } } -}
\ No newline at end of file +} diff --git a/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationReader.kt b/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationReader.kt index e712d6e5..e126d05f 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationReader.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationReader.kt @@ -65,11 +65,7 @@ private class ContextModuleAndPackageDocumentationReader( override fun get(module: DModule): SourceSetDependent<DocumentationNode> { return findDocumentationNodes(module.sourceSets) { fragment -> - fragment.classifier == Classifier.Module && ( - /* Match fragment name against module name or distinct module displayName */ - fragment.name == module.name || - fragment.name == module.sourceSets.map { it.moduleDisplayName }.distinct().singleOrNull() - ) + fragment.classifier == Classifier.Module && (fragment.name == module.name) } } diff --git a/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt index 2099cab5..ca239d83 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt @@ -62,12 +62,12 @@ abstract class SamplesTransformer(val context: DokkaContext) : PageTransformer { private fun ContentNode.addSample( contentPage: ContentPage, - platform: DokkaSourceSet, + sourceSet: DokkaSourceSet, fqName: String, analysis: Map<DokkaSourceSet, EnvironmentAndFacade> ): ContentNode { - val facade = analysis[platform]?.facade - ?: return this.also { context.logger.warn("Cannot resolve facade for platform ${platform.moduleDisplayName}") } + val facade = analysis[sourceSet]?.facade + ?: return this.also { context.logger.warn("Cannot resolve facade for platform ${sourceSet.sourceSetID}") } val psiElement = fqNameToPsiElement(facade, fqName) ?: return this.also { context.logger.warn("Cannot find PsiElement corresponding to $fqName") } val imports = diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index 18b05df4..8e5a1927 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -70,7 +70,15 @@ class DefaultDescriptorToDocumentableTranslator( DRIWithPlatformInfo(DRI.topLevel, emptyMap()) ) } - }.let { DModule(sourceSet.moduleDisplayName, it, emptyMap(), null, setOf(sourceSet)) } + }.let { + DModule( + name = context.configuration.moduleName, + packages = it, + documentation = emptyMap(), + expectPresentInSet = null, + sourceSets = setOf(sourceSet) + ) + } } } @@ -557,7 +565,9 @@ private class DokkaDescriptorVisitor( private fun ClassDescriptor.resolveClassDescriptionData(): ClassInfo { fun toTypeConstructor(kt: KotlinType) = - TypeConstructor(DRI.from(kt.constructor.declarationDescriptor as DeclarationDescriptor), kt.arguments.map { it.toProjection() }) + TypeConstructor( + DRI.from(kt.constructor.declarationDescriptor as DeclarationDescriptor), + kt.arguments.map { it.toProjection() }) tailrec fun buildAncestryInformation( supertypes: Collection<KotlinType>, @@ -753,13 +763,22 @@ private class DokkaDescriptorVisitor( private fun ValueArgument.childrenAsText() = this.safeAs<KtValueArgument>()?.children?.map { it.text }.orEmpty() - private data class AncestryLevel(val level: Int, val superclass: TypeConstructor?, val interfaces: List<TypeConstructor>) + private data class AncestryLevel( + val level: Int, + val superclass: TypeConstructor?, + val interfaces: List<TypeConstructor> + ) - private data class ClassInfo(val ancestry: List<AncestryLevel>, val docs: SourceSetDependent<DocumentationNode>){ + private data class ClassInfo(val ancestry: List<AncestryLevel>, val docs: SourceSetDependent<DocumentationNode>) { val supertypes: List<TypeConstructorWithKind> get() = ancestry.firstOrNull { it.level == 0 }?.let { - listOfNotNull(it.superclass?.let { TypeConstructorWithKind(it, KotlinClassKindTypes.CLASS) }) + it.interfaces.map { TypeConstructorWithKind(it, KotlinClassKindTypes.INTERFACE) } - }.orEmpty() + listOfNotNull(it.superclass?.let { + TypeConstructorWithKind( + it, + KotlinClassKindTypes.CLASS + ) + }) + it.interfaces.map { TypeConstructorWithKind(it, KotlinClassKindTypes.INTERFACE) } + }.orEmpty() val allImplementedInterfaces: List<TypeConstructor> get() = ancestry.flatMap { it.interfaces }.distinct() diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt index c1ed4a08..30e46404 100644 --- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt @@ -68,7 +68,7 @@ class DefaultPsiToDocumentableTranslator( context.logger ) return DModule( - sourceSet.moduleDisplayName, + context.configuration.moduleName, psiFiles.mapNotNull { it.safeAs<PsiJavaFile>() }.groupBy { it.packageName }.map { (packageName, psiFiles) -> val dri = DRI(packageName = packageName) DPackage( |