diff options
author | Vadim Mishenev <vad-mishenev@yandex.ru> | 2022-02-21 23:06:59 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-21 23:06:59 +0300 |
commit | c44bf5487bd32f90a4576859548f1db0e9355a07 (patch) | |
tree | 2954c68d9247007ecc255d397fb207b1cb2d1be1 /plugins/javadoc/src/main/kotlin/org | |
parent | f54597c754c9be6afb4ea374dc959dcc9fd551ce (diff) | |
download | dokka-c44bf5487bd32f90a4576859548f1db0e9355a07.tar.gz dokka-c44bf5487bd32f90a4576859548f1db0e9355a07.tar.bz2 dokka-c44bf5487bd32f90a4576859548f1db0e9355a07.zip |
Add option to merge implicit expect-actual declarations (#2316)
* Add option to merge implicit expect-actual declarations
* Merge entries, constructors
* Fix StdLib integration test
* Add doc
Diffstat (limited to 'plugins/javadoc/src/main/kotlin/org')
3 files changed, 48 insertions, 47 deletions
diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt index 96bcec70..61d45ae1 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/JavadocPageCreator.kt @@ -33,7 +33,7 @@ open class JavadocPageCreator(context: DokkaContext) { ) fun pageForPackage(p: DPackage) = - JavadocPackagePageNode(p.name, contentForPackage(p), setOf(p.dri), p, + JavadocPackagePageNode(p.name, contentForPackage(p), setOf(p.dri), listOf(p), p.classlikes.mapNotNull { pageForClasslike(it) } ) @@ -68,7 +68,7 @@ open class JavadocPageCreator(context: DokkaContext) { PropertyContainer.withAll(it.indexesInDocumentation()) ) }, - documentable = c, + documentables = listOf(c), children = children, extra = ((c as? WithExtraProperties<Documentable>)?.extra ?: PropertyContainer.empty()) + c.indexesInDocumentation() diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt index 572c5dec..6c7691cd 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/JavadocPageNodes.kt @@ -15,7 +15,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.resolve.DescriptorUtils.getClassDescriptorForType -interface JavadocPageNode : ContentPage +interface JavadocPageNode : ContentPage, WithDocumentables interface WithJavadocExtra<T : Documentable> : WithExtraProperties<T> { override fun withNewExtras(newExtras: PropertyContainer<T>): T = @@ -43,7 +43,7 @@ class JavadocModulePageNode( JavadocPageNode, ModulePage { - override val documentable: Documentable? = null + override val documentables: List<Documentable> = emptyList() override val embeddedResources: List<String> = emptyList() override fun modified(name: String, children: List<PageNode>): RootPageNode = JavadocModulePageNode(name, content, children, dri, extra) @@ -66,7 +66,7 @@ class JavadocPackagePageNode( override val content: JavadocContentNode, override val dri: Set<DRI>, - override val documentable: Documentable? = null, + override val documentables: List<Documentable> = emptyList(), override val children: List<PageNode> = emptyList(), override val embeddedResources: List<String> = listOf() ) : JavadocPageNode, @@ -91,7 +91,7 @@ class JavadocPackagePageNode( name, content, dri, - documentable, + documentables, children, embeddedResources ) @@ -107,7 +107,7 @@ class JavadocPackagePageNode( name, content as JavadocContentNode, dri, - documentable, + documentables, children, embeddedResources ) @@ -182,7 +182,7 @@ class JavadocClasslikePageNode( val classlikes: List<JavadocClasslikePageNode>, val properties: List<JavadocPropertyNode>, override val brief: List<ContentNode>, - override val documentable: Documentable? = null, + override val documentables: List<Documentable> = emptyList(), override val children: List<PageNode> = emptyList(), override val embeddedResources: List<String> = listOf(), override val extra: PropertyContainer<DClasslike> = PropertyContainer.empty(), @@ -194,7 +194,7 @@ class JavadocClasslikePageNode( fun getAnchorables(): List<AnchorableJavadocNode> = constructors + methods + entries + properties - val kind: String? = documentable?.kind() + val kind: String? = documentables.firstOrNull()?.kind() val packageName = dri.first().packageName override fun getId(): String = name @@ -215,7 +215,7 @@ class JavadocClasslikePageNode( classlikes, properties, brief, - documentable, + documentables, children, embeddedResources, extra @@ -240,7 +240,7 @@ class JavadocClasslikePageNode( classlikes, properties, brief, - documentable, + documentables, children, embeddedResources, extra @@ -254,7 +254,7 @@ class AllClassesPage(val classes: List<JavadocClasslikePageNode>) : JavadocPageN override val name: String = "All Classes" override val dri: Set<DRI> = setOf(DRI.topLevel) - override val documentable: Documentable? = null + override val documentables: List<Documentable> = emptyList() override val embeddedResources: List<String> = emptyList() override val content: ContentNode = @@ -285,7 +285,7 @@ class DeprecatedPage( ) : JavadocPageNode { override val name: String = "deprecated" override val dri: Set<DRI> = setOf(DRI.topLevel) - override val documentable: Documentable? = null + override val documentables: List<Documentable> = emptyList() override val children: List<PageNode> = emptyList() override val embeddedResources: List<String> = listOf() @@ -339,7 +339,7 @@ class IndexPage( ) : JavadocPageNode { override val name: String = "index-$id" override val dri: Set<DRI> = setOf(DRI.topLevel) - override val documentable: Documentable? = null + override val documentables: List<Documentable> = emptyList() override val children: List<PageNode> = emptyList() override val embeddedResources: List<String> = listOf() val title: String = "${keys[id - 1]}-index" @@ -370,7 +370,7 @@ class TreeViewPage( val packages: List<JavadocPackagePageNode>?, val classes: List<JavadocClasslikePageNode>?, override val dri: Set<DRI>, - override val documentable: Documentable?, + override val documentables: List<Documentable> = emptyList(), val root: PageNode ) : JavadocPageNode { init { @@ -378,7 +378,7 @@ class TreeViewPage( assert(packages != null || classes != null) } - private val documentables = root.children.filterIsInstance<ContentPage>().flatMap { node -> + private val childrenDocumentables = root.children.filterIsInstance<WithDocumentables>().flatMap { node -> getDocumentableEntries(node) }.groupBy({ it.first }) { it.second }.map { (l, r) -> l to r.first() }.toMap() @@ -389,12 +389,12 @@ class TreeViewPage( override val children: List<PageNode> = emptyList() - val title = when (documentable) { + val title = when (documentables.firstOrNull()) { is DPackage -> "$name Class Hierarchy" else -> "All packages" } - val kind = when (documentable) { + val kind = when (documentables.firstOrNull()) { is DPackage -> "package" else -> "main" } @@ -411,7 +411,7 @@ class TreeViewPage( packages = children.filterIsInstance<JavadocPackagePageNode>().takeIf { it.isNotEmpty() }, classes = children.filterIsInstance<JavadocClasslikePageNode>().takeIf { it.isNotEmpty() }, dri = dri, - documentable = documentable, + documentables, root = root ) @@ -421,7 +421,7 @@ class TreeViewPage( packages = children.filterIsInstance<JavadocPackagePageNode>().takeIf { it.isNotEmpty() }, classes = children.filterIsInstance<JavadocClasslikePageNode>().takeIf { it.isNotEmpty() }, dri = dri, - documentable = documentable, + documentables, root = root ) @@ -473,23 +473,25 @@ class TreeViewPage( listOf(psi to l) + l.flatMap { gatherPsiClasses(it) } } - val psiInheritanceTree = documentables.flatMap { (_, v) -> (v as? WithSources)?.sources?.values.orEmpty() } - .filterIsInstance<PsiDocumentableSource>().mapNotNull { it.psi as? PsiClass }.flatMap(::gatherPsiClasses) - .flatMap { entry -> entry.second.map { it to entry.first } } - .let { - it + it.map { it.second to null } - } - .groupBy({ it.first }) { it.second } - .map { it.key to it.value.filterNotNull().distinct() } - .map { (k, v) -> - InheritanceNode( - DRI.from(k), - v.map { InheritanceNode(DRI.from(it)) }, - k.supers.filter { it.isInterface }.map { DRI.from(it) }, - k.isInterface - ) - - } + val psiInheritanceTree = + childrenDocumentables.flatMap { (_, v) -> (v as? WithSources)?.sources?.values.orEmpty() } + .filterIsInstance<PsiDocumentableSource>().mapNotNull { it.psi as? PsiClass } + .flatMap(::gatherPsiClasses) + .flatMap { entry -> entry.second.map { it to entry.first } } + .let { + it + it.map { it.second to null } + } + .groupBy({ it.first }) { it.second } + .map { it.key to it.value.filterNotNull().distinct() } + .map { (k, v) -> + InheritanceNode( + DRI.from(k), + v.map { InheritanceNode(DRI.from(it)) }, + k.supers.filter { it.isInterface }.map { DRI.from(it) }, + k.isInterface + ) + + } val descriptorInheritanceTree = descriptorMap.flatMap { (_, v) -> v.typeConstructor.supertypes @@ -523,16 +525,17 @@ class TreeViewPage( } private fun generateInterfaceGraph() { - documentables.values.filterIsInstance<DInterface>() + childrenDocumentables.values.filterIsInstance<DInterface>() } - private fun getDocumentableEntries(node: ContentPage): List<Pair<DRI, Documentable>> = - listOfNotNull(node.documentable?.let { it.dri to it }) + - node.children.filterIsInstance<ContentPage>().flatMap(::getDocumentableEntries) + private fun getDocumentableEntries(node: WithDocumentables): List<Pair<DRI, Documentable>> = + node.documentables.map { it.dri to it } + + (node as? ContentPage)?.children?.filterIsInstance<WithDocumentables>() + ?.flatMap(::getDocumentableEntries).orEmpty() private fun getDescriptorMap(): Map<DRI, ClassDescriptor> { val map: MutableMap<DRI, ClassDescriptor> = mutableMapOf() - documentables + childrenDocumentables .mapNotNull { (k, v) -> v.descriptorForPlatform()?.let { k to it }?.also { (k, v) -> map[k] = v } }.map { it.second }.forEach { gatherSupertypes(it, map) } diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt index c04c7538..bef4108c 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/pages/htmlPreprocessors.kt @@ -4,12 +4,10 @@ import org.jetbrains.dokka.base.renderers.sourceSets import org.jetbrains.dokka.base.transformers.documentables.deprecatedAnnotation import org.jetbrains.dokka.base.transformers.documentables.isDeprecated import org.jetbrains.dokka.base.transformers.documentables.isException -import org.jetbrains.dokka.model.Documentable import org.jetbrains.dokka.model.BooleanValue -import org.jetbrains.dokka.model.WithSupertypes +import org.jetbrains.dokka.model.Documentable import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.transformers.pages.PageTransformer -import kotlin.collections.HashMap object ResourcesInstaller : PageTransformer { override fun invoke(input: RootPageNode): RootPageNode = input.modified( @@ -37,7 +35,7 @@ object TreeViewInstaller : PageTransformer { packages = node.children<JavadocPackagePageNode>().map { installPackageTreeNode(it, root) }, classes = null, dri = node.dri, - documentable = node.documentable, + documentables = node.documentables, root = root ) @@ -55,7 +53,7 @@ object TreeViewInstaller : PageTransformer { packages = null, classes = node.children.filterIsInstance<JavadocClasslikePageNode>(), dri = node.dri, - documentable = node.documentable, + documentables = node.documentables, root = root ) |