aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/parsers/MarkdownParser.kt
diff options
context:
space:
mode:
authorAndrzej Ratajczak <andrzej.ratajczak98@gmail.com>2020-02-03 14:09:19 +0100
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-02-06 10:53:43 +0100
commitf7c67c2ade8b56c6556ec59d9c0adf8643a8e566 (patch)
tree942141e9b60b1a728298cd9051eb1c709d4b1569 /core/src/main/kotlin/parsers/MarkdownParser.kt
parent356502980c217b7275971619fabb22acfe1a3d55 (diff)
downloaddokka-f7c67c2ade8b56c6556ec59d9c0adf8643a8e566.tar.gz
dokka-f7c67c2ade8b56c6556ec59d9c0adf8643a8e566.tar.bz2
dokka-f7c67c2ade8b56c6556ec59d9c0adf8643a8e566.zip
Resolves bugs with doubling references and fixes minor bugs
Diffstat (limited to 'core/src/main/kotlin/parsers/MarkdownParser.kt')
-rw-r--r--core/src/main/kotlin/parsers/MarkdownParser.kt14
1 files changed, 11 insertions, 3 deletions
diff --git a/core/src/main/kotlin/parsers/MarkdownParser.kt b/core/src/main/kotlin/parsers/MarkdownParser.kt
index 5e4b82e8..30a507df 100644
--- a/core/src/main/kotlin/parsers/MarkdownParser.kt
+++ b/core/src/main/kotlin/parsers/MarkdownParser.kt
@@ -1,5 +1,6 @@
package org.jetbrains.dokka.parsers
+import com.intellij.psi.PsiElement
import org.jetbrains.dokka.model.doc.*
import org.intellij.markdown.MarkdownElementTypes
import org.intellij.markdown.MarkdownTokenTypes
@@ -14,6 +15,9 @@ import org.jetbrains.dokka.utilities.DokkaConsoleLogger
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.idea.kdoc.resolveKDocLink
import org.jetbrains.kotlin.kdoc.parser.KDocKnownTag
+import org.jetbrains.kotlin.kdoc.psi.api.KDoc
+import org.jetbrains.kotlin.kdoc.psi.impl.KDocImpl
+import org.jetbrains.kotlin.kdoc.psi.impl.KDocSection
import org.jetbrains.kotlin.kdoc.psi.impl.KDocTag
import org.intellij.markdown.parser.MarkdownParser as IntellijMarkdownParser
@@ -186,12 +190,18 @@ class MarkdownParser (
override fun parseStringToDocNode(extractedString: String) = markdownToDocNode(extractedString)
override fun preparse(text: String) = text
+ private fun findParent(kDoc: PsiElement): PsiElement =
+ if(kDoc is KDocSection) findParent(kDoc.parent) else kDoc
+
+ private fun getAllKDocTags(kDocImpl: PsiElement): List<KDocTag> =
+ kDocImpl.children.filterIsInstance<KDocTag>().filterNot { it is KDocSection } + kDocImpl.children.flatMap { getAllKDocTags(it) }
+
fun parseFromKDocTag(kDocTag: KDocTag?): DocumentationNode {
return if(kDocTag == null)
DocumentationNode(emptyList())
else
DocumentationNode(
- (listOf(kDocTag) + kDocTag.children).filterIsInstance<KDocTag>().map {
+ (listOf(kDocTag) + getAllKDocTags(findParent(kDocTag) as KDocImpl)).map {
when (it.knownTag) {
null -> if (it.name == null) Description(parseStringToDocNode(it.getContent())) else CustomWrapperTag(
parseStringToDocNode(it.getContent()),
@@ -213,6 +223,4 @@ class MarkdownParser (
}
)
}
-
-
} \ No newline at end of file