aboutsummaryrefslogtreecommitdiff
path: root/src/Kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'src/Kotlin')
-rw-r--r--src/Kotlin/ContentBuilder.kt81
-rw-r--r--src/Kotlin/DocumentationBuilder.kt19
2 files changed, 42 insertions, 58 deletions
diff --git a/src/Kotlin/ContentBuilder.kt b/src/Kotlin/ContentBuilder.kt
index 635fc74f..8079fb4c 100644
--- a/src/Kotlin/ContentBuilder.kt
+++ b/src/Kotlin/ContentBuilder.kt
@@ -1,23 +1,22 @@
package org.jetbrains.dokka
-import org.jetbrains.markdown.MarkdownElementTypes
import java.util.ArrayDeque
-import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
-import org.jetbrains.jet.lang.resolve.name.Name
-import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
-import org.jetbrains.jet.lang.resolve.scopes.JetScope
-import org.jetbrains.jet.lang.resolve.name.FqName
+import org.jetbrains.jet.lang.descriptors.*
+import org.jetbrains.jet.lang.resolve.*
+import org.jetbrains.jet.lang.resolve.scopes.*
+import org.jetbrains.jet.lang.resolve.name.*
+import net.nicoulaj.idea.markdown.lang.*
-public fun DocumentationBuilder.buildContent(tree: MarkdownTree, descriptor: DeclarationDescriptor): Content {
+public fun DocumentationBuilder.buildContent(tree: MarkdownNode, descriptor: DeclarationDescriptor): Content {
val nodeStack = ArrayDeque<ContentNode>()
nodeStack.push(Content())
- tree.visit {(node, text, processChildren) ->
+ tree.visit {(node, processChildren) ->
val parent = nodeStack.peek()!!
- val nodeType = node.getTokenType()
- val nodeText = tree.getNodeText(node)
+ val nodeType = node.type
+ val nodeText = tree.text
when (nodeType) {
- MarkdownElementTypes.BULLET_LIST -> {
+ MarkdownElementTypes.UNORDERED_LIST -> {
nodeStack.push(ContentList())
processChildren()
parent.append(nodeStack.pop())
@@ -27,9 +26,7 @@ public fun DocumentationBuilder.buildContent(tree: MarkdownTree, descriptor: Dec
processChildren()
parent.append(nodeStack.pop())
}
- MarkdownElementTypes.HORIZONTAL_RULE -> {
- }
- MarkdownElementTypes.LIST_BLOCK -> {
+ MarkdownElementTypes.LIST_ITEM -> {
nodeStack.push(ContentBlock())
processChildren()
parent.append(nodeStack.pop())
@@ -44,50 +41,42 @@ public fun DocumentationBuilder.buildContent(tree: MarkdownTree, descriptor: Dec
processChildren()
parent.append(nodeStack.pop())
}
- MarkdownElementTypes.CODE -> {
+ MarkdownTokenTypes.CODE -> {
nodeStack.push(ContentCode())
processChildren()
parent.append(nodeStack.pop())
}
- MarkdownElementTypes.ANONYMOUS_SECTION -> {
- nodeStack.push(ContentSection(""))
- processChildren()
- parent.append(nodeStack.pop())
- }
- MarkdownElementTypes.DIRECTIVE -> {
- val name = tree.findChildByType(node, MarkdownElementTypes.DIRECTIVE_NAME)?.let { tree.getNodeText(it) } ?: ""
- val params = tree.findChildByType(node, MarkdownElementTypes.DIRECTIVE_PARAMS)?.let { tree.getNodeText(it) } ?: ""
- when (name) {
- "code" -> parent.append(functionBody(descriptor, params))
- }
- }
- MarkdownElementTypes.NAMED_SECTION -> {
- val label = tree.findChildByType(node, MarkdownElementTypes.SECTION_NAME)?.let { tree.getNodeText(it) } ?: ""
- nodeStack.push(ContentSection(label))
- processChildren()
- parent.append(nodeStack.pop())
- }
- MarkdownElementTypes.LINK -> {
- val target = tree.findChildByType(node, MarkdownElementTypes.TARGET)?.let { tree.getNodeText(it) } ?: ""
- val href = tree.findChildByType(node, MarkdownElementTypes.HREF)?.let { tree.getNodeText(it) }
+ /* MarkdownElementTypes.ANONYMOUS_SECTION -> {
+ nodeStack.push(ContentSection(""))
+ processChildren()
+ parent.append(nodeStack.pop())
+ }
+ MarkdownElementTypes.DIRECTIVE -> {
+ val name = tree.findChildByType(node, MarkdownElementTypes.DIRECTIVE_NAME)?.let { tree.getNodeText(it) } ?: ""
+ val params = tree.findChildByType(node, MarkdownElementTypes.DIRECTIVE_PARAMS)?.let { tree.getNodeText(it) } ?: ""
+ when (name) {
+ "code" -> parent.append(functionBody(descriptor, params))
+ }
+ }
+ MarkdownElementTypes.NAMED_SECTION -> {
+ val label = tree.findChildByType(node, MarkdownElementTypes.SECTION_NAME)?.let { tree.getNodeText(it) } ?: ""
+ nodeStack.push(ContentSection(label))
+ processChildren()
+ parent.append(nodeStack.pop())
+ }*/
+ MarkdownElementTypes.INLINE_LINK -> {
+ val target = node.child(MarkdownElementTypes.LINK_TITLE)?.let { it.text } ?: ""
+ val href = node.child(MarkdownElementTypes.LINK_DESTINATION)?.let { it.text }
val link = if (href != null) ContentExternalLink(href) else ContentExternalLink(target)
link.append(ContentText(target))
parent.append(link)
}
- MarkdownElementTypes.PLAIN_TEXT -> {
+ MarkdownTokenTypes.TEXT -> {
nodeStack.push(ContentText(nodeText))
processChildren()
parent.append(nodeStack.pop())
}
- MarkdownElementTypes.END_LINE -> {
- nodeStack.push(ContentText(nodeText))
- processChildren()
- parent.append(nodeStack.pop())
- }
- MarkdownElementTypes.BLANK_LINE -> {
- processChildren()
- }
- MarkdownElementTypes.PARA -> {
+ MarkdownElementTypes.PARAGRAPH -> {
nodeStack.push(ContentParagraph())
processChildren()
parent.append(nodeStack.pop())
diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt
index 0acff1dc..d8be9d5a 100644
--- a/src/Kotlin/DocumentationBuilder.kt
+++ b/src/Kotlin/DocumentationBuilder.kt
@@ -1,17 +1,12 @@
package org.jetbrains.dokka
import org.jetbrains.jet.lang.descriptors.*
-import org.jetbrains.dokka.DocumentationNode.Kind
-import org.jetbrains.jet.lang.types.TypeProjection
-import org.jetbrains.jet.lang.types.Variance
-import org.jetbrains.jet.lang.types.JetType
-import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
-import org.jetbrains.jet.lang.resolve.BindingContext
-import org.jetbrains.jet.lang.resolve.name.Name
-import org.jetbrains.jet.lang.resolve.scopes.JetScope
-import org.jetbrains.jet.lang.psi.JetFile
-import org.jetbrains.jet.lang.resolve.name.FqName
-import org.jetbrains.jet.lang.resolve.lazy.ResolveSession
+import org.jetbrains.dokka.DocumentationNode.*
+import org.jetbrains.jet.lang.types.*
+import org.jetbrains.jet.lang.types.lang.*
+import org.jetbrains.jet.lang.resolve.scopes.*
+import org.jetbrains.jet.lang.resolve.name.*
+import org.jetbrains.jet.lang.resolve.lazy.*
public data class DocumentationOptions(val includeNonPublic: Boolean = false)
@@ -24,7 +19,7 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati
fun parseDocumentation(descriptor: DeclarationDescriptor): Content {
val docText = descriptor.getDocumentationElements().map { it.extractText() }.join("\n")
- val tree = MarkdownProcessor.parse(docText)
+ val tree = parseMarkdown(docText)
//println(tree.toTestString())
val content = buildContent(tree, descriptor)
return content