diff options
Diffstat (limited to 'plugins/base/src/main/kotlin')
-rw-r--r-- | plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationReader.kt | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationReader.kt b/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationReader.kt index e126d05f..6e26377e 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationReader.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/ModuleAndPackageDocumentationReader.kt @@ -12,7 +12,8 @@ import org.jetbrains.dokka.base.parsers.moduleAndPackage.parseModuleAndPackageDo import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.model.DPackage import org.jetbrains.dokka.model.SourceSetDependent -import org.jetbrains.dokka.model.doc.DocumentationNode +import org.jetbrains.dokka.model.doc.* +import org.jetbrains.dokka.model.doc.Deprecated import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.utilities.associateWithNotNull @@ -51,7 +52,8 @@ private class ContextModuleAndPackageDocumentationReader( when (documentations.size) { 0 -> null 1 -> documentations.single().documentation - else -> DocumentationNode(documentations.flatMap { it.documentation.children }) + else -> DocumentationNode(documentations.flatMap { it.documentation.children } + .mergeDocumentationNodes()) } } } @@ -74,4 +76,31 @@ private class ContextModuleAndPackageDocumentationReader( fragment.classifier == Classifier.Package && fragment.canonicalPackageName == pkg.dri.packageName } } + + private fun List<TagWrapper>.mergeDocumentationNodes(): List<TagWrapper> = + groupBy { it::class }.values.map { + it.reduce { acc, tagWrapper -> + val newRoot = CustomDocTag( + acc.children + tagWrapper.children, + name = (tagWrapper as? NamedTagWrapper)?.name.orEmpty() + ) + when (acc) { + is See -> acc.copy(newRoot) + is Param -> acc.copy(newRoot) + is Throws -> acc.copy(newRoot) + is Sample -> acc.copy(newRoot) + is Property -> acc.copy(newRoot) + is CustomTagWrapper -> acc.copy(newRoot) + is Description -> acc.copy(newRoot) + is Author -> acc.copy(newRoot) + is Version -> acc.copy(newRoot) + is Since -> acc.copy(newRoot) + is Return -> acc.copy(newRoot) + is Receiver -> acc.copy(newRoot) + is Constructor -> acc.copy(newRoot) + is Deprecated -> acc.copy(newRoot) + is org.jetbrains.dokka.model.doc.Suppress -> acc.copy(newRoot) + } + } + } } |