aboutsummaryrefslogtreecommitdiff
path: root/src/CommentsAPI.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/CommentsAPI.kt')
-rw-r--r--src/CommentsAPI.kt17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/CommentsAPI.kt b/src/CommentsAPI.kt
index 21ba1067..fd281899 100644
--- a/src/CommentsAPI.kt
+++ b/src/CommentsAPI.kt
@@ -1,7 +1,6 @@
package com.jetbrains.dokka
import org.jetbrains.jet.lang.descriptors.*
-import org.jetbrains.jet.lexer.*
import org.jetbrains.jet.lang.resolve.*
import org.jetbrains.jet.kdoc.psi.api.*
import org.jetbrains.jet.lang.psi.JetDeclaration
@@ -12,3 +11,19 @@ fun BindingContext.getDocumentation(descriptor: DeclarationDescriptor): KDoc? {
return psiElement.previousSiblings().takeWhile { it !is JetDeclaration }.firstOrNull { it is KDoc } as KDoc?
}
+
+fun KDoc?.extractText(): String {
+ if (this == null)
+ return ""
+ val text = getText()
+ if (text == null)
+ return ""
+ val lines = text.replace("\r", "").split("\n")
+ return lines.map {
+ it.dropWhile { java.lang.Character.isWhitespace(it) }
+ .dropWhile { it == '/' }
+ .dropWhile { it == '*' }
+ .dropWhile { it == '/' }
+ .dropWhile { java.lang.Character.isWhitespace(it) }
+ }.filter { it.any() }.join("\n")
+} \ No newline at end of file