aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/parsers/HtmlParser.kt6
-rw-r--r--core/src/main/kotlin/parsers/MarkdownParser.kt36
-rw-r--r--core/src/main/kotlin/parsers/factories/DocTagsFromIElementFactory.kt (renamed from core/src/main/kotlin/parsers/factories/DocNodesFromIElementFactory.kt)2
-rw-r--r--core/src/main/kotlin/parsers/factories/DocTagsFromStringFactory.kt (renamed from core/src/main/kotlin/parsers/factories/DocNodesFromStringFactory.kt)2
4 files changed, 21 insertions, 25 deletions
diff --git a/core/src/main/kotlin/parsers/HtmlParser.kt b/core/src/main/kotlin/parsers/HtmlParser.kt
index aebdee41..a0652b95 100644
--- a/core/src/main/kotlin/parsers/HtmlParser.kt
+++ b/core/src/main/kotlin/parsers/HtmlParser.kt
@@ -1,7 +1,7 @@
package org.jetbrains.dokka.parsers
import org.jetbrains.dokka.model.doc.*
-import org.jetbrains.dokka.parsers.factories.DocNodesFromStringFactory
+import org.jetbrains.dokka.parsers.factories.DocTagsFromStringFactory
import org.jsoup.Jsoup
import org.jsoup.nodes.Node
import org.jsoup.select.NodeFilter
@@ -36,12 +36,12 @@ class HtmlParser : Parser() {
}
val docNode = if(depth < currentDepth) {
- DocNodesFromStringFactory.getInstance(nodeName, nodesCache.getOrDefault(currentDepth, mutableListOf()).toList(), params, body).also {
+ DocTagsFromStringFactory.getInstance(nodeName, nodesCache.getOrDefault(currentDepth, mutableListOf()).toList(), params, body).also {
nodesCache[currentDepth] = mutableListOf()
currentDepth = depth
}
} else {
- DocNodesFromStringFactory.getInstance(nodeName, emptyList(), params, body)
+ DocTagsFromStringFactory.getInstance(nodeName, emptyList(), params, body)
}
nodesCache.getOrDefault(depth, mutableListOf()) += docNode
diff --git a/core/src/main/kotlin/parsers/MarkdownParser.kt b/core/src/main/kotlin/parsers/MarkdownParser.kt
index 6afcbee6..23315e23 100644
--- a/core/src/main/kotlin/parsers/MarkdownParser.kt
+++ b/core/src/main/kotlin/parsers/MarkdownParser.kt
@@ -1,8 +1,6 @@
package org.jetbrains.dokka.parsers
import com.intellij.psi.PsiElement
-import org.intellij.markdown.IElementType
-import org.intellij.markdown.MarkdownElementType
import org.jetbrains.dokka.model.doc.*
import org.intellij.markdown.MarkdownElementTypes
import org.intellij.markdown.MarkdownTokenTypes
@@ -13,12 +11,10 @@ import org.intellij.markdown.ast.impl.ListItemCompositeNode
import org.intellij.markdown.flavours.commonmark.CommonMarkFlavourDescriptor
import org.jetbrains.dokka.analysis.DokkaResolutionFacade
import org.jetbrains.dokka.links.DRI
-import org.jetbrains.dokka.parsers.factories.DocNodesFromIElementFactory
-import org.jetbrains.dokka.utilities.DokkaConsoleLogger
+import org.jetbrains.dokka.parsers.factories.DocTagsFromIElementFactory
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.impl.KDocImpl
import org.jetbrains.kotlin.kdoc.psi.impl.KDocSection
import org.jetbrains.kotlin.kdoc.psi.impl.KDocTag
import java.net.MalformedURLException
@@ -32,23 +28,23 @@ class MarkdownParser (
inner class MarkdownVisitor(val text: String, val destinationLinksMap: Map<String, String>) {
private fun headersHandler(node: ASTNode): DocTag =
- DocNodesFromIElementFactory.getInstance(
+ DocTagsFromIElementFactory.getInstance(
node.type,
visitNode(node.children.find { it.type == MarkdownTokenTypes.ATX_CONTENT } ?:
throw IllegalStateException("Wrong AST Tree. ATX Header does not contain expected content")).children
)
private fun horizontalRulesHandler(node: ASTNode): DocTag =
- DocNodesFromIElementFactory.getInstance(MarkdownTokenTypes.HORIZONTAL_RULE)
+ DocTagsFromIElementFactory.getInstance(MarkdownTokenTypes.HORIZONTAL_RULE)
private fun emphasisHandler(node: ASTNode): DocTag =
- DocNodesFromIElementFactory.getInstance(
+ DocTagsFromIElementFactory.getInstance(
node.type,
children = listOf(visitNode(node.children[node.children.size / 2]))
)
private fun blockquotesHandler(node: ASTNode): DocTag =
- DocNodesFromIElementFactory.getInstance(node.type, children = node.children
+ DocTagsFromIElementFactory.getInstance(node.type, children = node.children
.filterIsInstance<CompositeASTNode>()
.evaluateChildren())
@@ -64,13 +60,13 @@ class MarkdownParser (
listOf(it)
}
- return DocNodesFromIElementFactory.getInstance(
+ return DocTagsFromIElementFactory.getInstance(
node.type,
children =
children
.map {
if(it.type == MarkdownElementTypes.LIST_ITEM)
- DocNodesFromIElementFactory.getInstance(
+ DocTagsFromIElementFactory.getInstance(
it.type,
children = it
.children
@@ -141,7 +137,7 @@ class MarkdownParser (
else
mapOf("href" to link, "title" to text.substring(linkTitle.startOffset + 1, linkTitle.endOffset - 1))
- return DocNodesFromIElementFactory.getInstance(MarkdownElementTypes.INLINE_LINK, params = params, children = linkText.children.drop(1).dropLast(1).evaluateChildren(), dri = dri)
+ return DocTagsFromIElementFactory.getInstance(MarkdownElementTypes.INLINE_LINK, params = params, children = linkText.children.drop(1).dropLast(1).evaluateChildren(), dri = dri)
}
private fun imagesHandler(node: ASTNode): DocTag {
@@ -149,14 +145,14 @@ class MarkdownParser (
node.children.last().children.find { it.type == MarkdownElementTypes.LINK_LABEL }!!.children[1]
val link = text.substring(linkNode.startOffset, linkNode.endOffset)
val src = mapOf("src" to link)
- return DocNodesFromIElementFactory.getInstance(node.type, params = src, children = listOf(visitNode(node.children.last().children.find { it.type == MarkdownElementTypes.LINK_TEXT }!!)))
+ return DocTagsFromIElementFactory.getInstance(node.type, params = src, children = listOf(visitNode(node.children.last().children.find { it.type == MarkdownElementTypes.LINK_TEXT }!!)))
}
private fun codeSpansHandler(node: ASTNode): DocTag =
- DocNodesFromIElementFactory.getInstance(
+ DocTagsFromIElementFactory.getInstance(
node.type,
children = listOf(
- DocNodesFromIElementFactory.getInstance(
+ DocTagsFromIElementFactory.getInstance(
MarkdownTokenTypes.TEXT,
body = text.substring(node.startOffset+1, node.endOffset-1).replace('\n', ' ').trimIndent()
)
@@ -165,7 +161,7 @@ class MarkdownParser (
)
private fun codeFencesHandler(node: ASTNode): DocTag =
- DocNodesFromIElementFactory.getInstance(
+ DocTagsFromIElementFactory.getInstance(
node.type,
children = node
.children
@@ -185,10 +181,10 @@ class MarkdownParser (
)
private fun codeBlocksHandler(node: ASTNode): DocTag =
- DocNodesFromIElementFactory.getInstance(node.type, children = node.children.evaluateChildren())
+ DocTagsFromIElementFactory.getInstance(node.type, children = node.children.evaluateChildren())
private fun defaultHandler(node: ASTNode): DocTag =
- DocNodesFromIElementFactory.getInstance(
+ DocTagsFromIElementFactory.getInstance(
MarkdownElementTypes.PARAGRAPH,
children = node.children.evaluateChildren())
@@ -214,10 +210,10 @@ class MarkdownParser (
MarkdownElementTypes.CODE_FENCE -> codeFencesHandler(node)
MarkdownElementTypes.CODE_SPAN -> codeSpansHandler(node)
MarkdownElementTypes.IMAGE -> imagesHandler(node)
- MarkdownTokenTypes.HARD_LINE_BREAK -> DocNodesFromIElementFactory.getInstance(node.type)
+ MarkdownTokenTypes.HARD_LINE_BREAK -> DocTagsFromIElementFactory.getInstance(node.type)
MarkdownTokenTypes.CODE_FENCE_CONTENT,
MarkdownTokenTypes.CODE_LINE,
- MarkdownTokenTypes.TEXT -> DocNodesFromIElementFactory.getInstance(
+ MarkdownTokenTypes.TEXT -> DocTagsFromIElementFactory.getInstance(
MarkdownTokenTypes.TEXT,
body = text
.substring(node.startOffset, node.endOffset).transform()
diff --git a/core/src/main/kotlin/parsers/factories/DocNodesFromIElementFactory.kt b/core/src/main/kotlin/parsers/factories/DocTagsFromIElementFactory.kt
index d4c6e752..e616b9e8 100644
--- a/core/src/main/kotlin/parsers/factories/DocNodesFromIElementFactory.kt
+++ b/core/src/main/kotlin/parsers/factories/DocTagsFromIElementFactory.kt
@@ -7,7 +7,7 @@ import org.intellij.markdown.MarkdownTokenTypes
import org.jetbrains.dokka.links.DRI
import java.lang.NullPointerException
-object DocNodesFromIElementFactory {
+object DocTagsFromIElementFactory {
fun getInstance(type: IElementType, children: List<DocTag> = emptyList(), params: Map<String, String> = emptyMap(), body: String? = null, dri: DRI? = null) =
when(type) {
MarkdownElementTypes.SHORT_REFERENCE_LINK,
diff --git a/core/src/main/kotlin/parsers/factories/DocNodesFromStringFactory.kt b/core/src/main/kotlin/parsers/factories/DocTagsFromStringFactory.kt
index 4ff9a9d4..3425f52e 100644
--- a/core/src/main/kotlin/parsers/factories/DocNodesFromStringFactory.kt
+++ b/core/src/main/kotlin/parsers/factories/DocTagsFromStringFactory.kt
@@ -4,7 +4,7 @@ import org.jetbrains.dokka.model.doc.*
import org.jetbrains.dokka.links.DRI
import java.lang.NullPointerException
-object DocNodesFromStringFactory {
+object DocTagsFromStringFactory {
fun getInstance(name: String, children: List<DocTag> = emptyList(), params: Map<String, String> = emptyMap(), body: String? = null, dri: DRI? = null) =
when(name) {
"a" -> A(children, params)