aboutsummaryrefslogtreecommitdiff
path: root/src/Kotlin
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2015-01-30 19:01:40 +0100
committerDmitry Jemerov <yole@jetbrains.com>2015-01-30 19:01:40 +0100
commit0fac1d925b74f24002a4e1538088ce66c4b02cb9 (patch)
tree5cf3800e961b9da84b2db03707603865496f5ed0 /src/Kotlin
parentbfd9ffd13ed6b6916790f5f0de5f9523db71b22e (diff)
downloaddokka-0fac1d925b74f24002a4e1538088ce66c4b02cb9.tar.gz
dokka-0fac1d925b74f24002a4e1538088ce66c4b02cb9.tar.bz2
dokka-0fac1d925b74f24002a4e1538088ce66c4b02cb9.zip
code review
Diffstat (limited to 'src/Kotlin')
-rw-r--r--src/Kotlin/ContentBuilder.kt2
-rw-r--r--src/Kotlin/DocumentationBuilder.kt14
2 files changed, 10 insertions, 6 deletions
diff --git a/src/Kotlin/ContentBuilder.kt b/src/Kotlin/ContentBuilder.kt
index 95e08c92..35beec54 100644
--- a/src/Kotlin/ContentBuilder.kt
+++ b/src/Kotlin/ContentBuilder.kt
@@ -112,7 +112,7 @@ public fun DocumentationBuilder.buildContentTo(tree: MarkdownNode, target: Conte
private fun keepWhitespace(node: ContentNode) = node is ContentParagraph || node is ContentSection
public fun DocumentationBuilder.buildInlineContentTo(tree: MarkdownNode, target: ContentNode) {
- val inlineContent = tree.children.firstOrNull { it.type == MarkdownElementTypes.PARAGRAPH }?.children ?: listOf(tree)
+ val inlineContent = tree.children.singleOrNull { it.type == MarkdownElementTypes.PARAGRAPH }?.children ?: listOf(tree)
inlineContent.forEach {
buildContentTo(it, target)
}
diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt
index 053615bc..c0533437 100644
--- a/src/Kotlin/DocumentationBuilder.kt
+++ b/src/Kotlin/DocumentationBuilder.kt
@@ -41,13 +41,15 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati
fun parseDocumentation(descriptor: DeclarationDescriptor): Content {
val kdoc = findKDoc(descriptor)
- val docText = kdoc?.getContent() ?: ""
- val tree = parseMarkdown(docText)
+ if (kdoc == null) {
+ return Content.Empty
+ }
+ val tree = parseMarkdown(kdoc.getContent())
//println(tree.toTestString())
val content = buildContent(tree)
if (kdoc is KDocSection) {
- val tags = PsiTreeUtil.getChildrenOfType(kdoc, javaClass<KDocTag>())
- tags?.forEach {
+ val tags = kdoc.getTags()
+ tags.forEach {
if (it.getName() == "code") {
content.append(functionBody(descriptor, it.getContent()))
} else {
@@ -61,11 +63,13 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati
return content
}
+ fun KDocSection.getTags(): Array<KDocTag> = PsiTreeUtil.getChildrenOfType(this, javaClass<KDocTag>()) ?: array()
+
fun displayName(sectionName: String?): String? =
when(sectionName) {
"param" -> "Parameters"
"throws", "exception" -> "Exceptions"
- else -> sectionName
+ else -> sectionName?.capitalize()
}
fun link(node: DocumentationNode, descriptor: DeclarationDescriptor) {