aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/transformers
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/kotlin/transformers')
-rw-r--r--core/src/main/kotlin/transformers/descriptors/DefaultDescriptorToDocumentationTranslator.kt38
-rw-r--r--core/src/main/kotlin/transformers/documentation/DefaultDocumentationNodeMerger.kt9
2 files changed, 10 insertions, 37 deletions
diff --git a/core/src/main/kotlin/transformers/descriptors/DefaultDescriptorToDocumentationTranslator.kt b/core/src/main/kotlin/transformers/descriptors/DefaultDescriptorToDocumentationTranslator.kt
index 4ffa4295..bdd345f1 100644
--- a/core/src/main/kotlin/transformers/descriptors/DefaultDescriptorToDocumentationTranslator.kt
+++ b/core/src/main/kotlin/transformers/descriptors/DefaultDescriptorToDocumentationTranslator.kt
@@ -12,15 +12,13 @@ import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.impl.DeclarationDescriptorVisitorEmptyBodies
import org.jetbrains.kotlin.idea.kdoc.findKDoc
-import org.jetbrains.kotlin.idea.kdoc.resolveKDocLink
-import org.jetbrains.kotlin.kdoc.psi.impl.KDocLink
-import org.jetbrains.kotlin.kdoc.psi.impl.KDocName
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
import org.jetbrains.kotlin.resolve.descriptorUtil.getAllSuperclassesWithoutAny
import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperInterfaces
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.resolve.scopes.MemberScope
import org.jetbrains.kotlin.types.KotlinType
+import parsers.MarkdownParser
object DefaultDescriptorToDocumentationTranslator: DescriptorToDocumentationTranslator {
override fun invoke(
@@ -36,7 +34,7 @@ object DefaultDescriptorToDocumentationTranslator: DescriptorToDocumentationTran
class DokkaDescriptorVisitor(
private val platformData: PlatformData,
private val resolutionFacade: DokkaResolutionFacade
-) : DeclarationDescriptorVisitorEmptyBodies<DocumentationNode, DRI>() {
+) : DeclarationDescriptorVisitorEmptyBodies<Documentable, DRI>() {
override fun visitDeclarationDescriptor(descriptor: DeclarationDescriptor, parent: DRI): Nothing {
throw IllegalStateException("${javaClass.simpleName} should never enter ${descriptor.javaClass.simpleName}")
}
@@ -69,7 +67,7 @@ class DokkaDescriptorVisitor(
scope.classes(dri),
descriptor.takeIf { it.isExpect }?.resolveClassDescriptionData(),
listOfNotNull(descriptorData),
- getXMLDRIs(descriptor, descriptorData).toMutableSet()
+ mutableSetOf() // TODO Implement following method to return proper results getXMLDRIs(descriptor, descriptorData).toMutableSet()
)
}
@@ -147,39 +145,15 @@ class DokkaDescriptorVisitor(
private fun DeclarationDescriptor.resolveDescriptorData(): PlatformInfo {
val doc = findKDoc()
- val links = doc?.children?.filter { it is KDocLink }?.flatMap { link ->
- val destination = link.children.first { it is KDocName }.text
- resolveKDocLink(
- resolutionFacade.resolveSession.bindingContext,
- resolutionFacade,
- this,
- null,
- destination.split('.')
- ).map { Pair(destination, DRI.from(it)) }
- }?.toMap() ?: emptyMap()
- return BasePlatformInfo(doc, links, listOf(platformData))
+ val parser: MarkdownParser = MarkdownParser(resolutionFacade, this)
+ val docHeader = parser.parseFromKDocTag(doc)
+ return BasePlatformInfo(docHeader, listOf(platformData))
}
private fun ClassDescriptor.resolveClassDescriptionData(): ClassPlatformInfo {
return ClassPlatformInfo(resolveDescriptorData(),
(getSuperInterfaces() + getAllSuperclassesWithoutAny()).map { DRI.from(it) })
}
-
- private fun getXMLDRIs(descriptor: DeclarationDescriptor, platformInfo: PlatformInfo?) =
- platformInfo?.docTag?.children
- ?.filter {
- it.text.contains("@attr")
- }?.flatMap { ref ->
- val matchResult = "@attr\\s+ref\\s+(.+)".toRegex().matchEntire(ref.text)
- val toFind = matchResult?.groups?.last()?.value.orEmpty()
- resolveKDocLink(
- resolutionFacade.resolveSession.bindingContext,
- resolutionFacade,
- descriptor,
- null,
- toFind.split('.')
- ).map { XMLMega("@attr ref", DRI.from(it)) }
- }.orEmpty()
}
data class XMLMega(val key: String, val dri: DRI) : Extra
diff --git a/core/src/main/kotlin/transformers/documentation/DefaultDocumentationNodeMerger.kt b/core/src/main/kotlin/transformers/documentation/DefaultDocumentationNodeMerger.kt
index 2b00c582..ef0f48d6 100644
--- a/core/src/main/kotlin/transformers/documentation/DefaultDocumentationNodeMerger.kt
+++ b/core/src/main/kotlin/transformers/documentation/DefaultDocumentationNodeMerger.kt
@@ -14,14 +14,13 @@ internal object DefaultDocumentationNodeMerger : DocumentationNodeMerger {
)
}
-private fun <T: DocumentationNode> merge(elements: List<T>, reducer: (T, T) -> T): List<T> =
+private fun <T: Documentable> merge(elements: List<T>, reducer: (T, T) -> T): List<T> =
elements.groupingBy { it.dri }
.reduce { _, left, right -> reducer(left, right)}
.values.toList()
fun PlatformInfo.mergeWith(other: PlatformInfo?) = BasePlatformInfo(
- docTag,
- links,
+ documentationNode,
(platformData + (other?.platformData ?: emptyList())).distinct()
)
@@ -31,12 +30,12 @@ fun ClassPlatformInfo.mergeWith(other: ClassPlatformInfo?) = ClassPlatformInfo(
)
fun List<ClassPlatformInfo>.mergeClassPlatformInfo() : List<ClassPlatformInfo> =
- groupingBy { it.docTag.toString() + it.links + it.inherited}.reduce {
+ groupingBy { it.documentationNode.children + it.inherited}.reduce {
_, left, right -> left.mergeWith(right)
}.values.toList()
fun List<PlatformInfo>.merge() : List<PlatformInfo> =
- groupingBy { it.docTag.toString() + it.links }.reduce {
+ groupingBy { it.documentationNode }.reduce {
_, left, right -> left.mergeWith(right)
}.values.toList()