diff options
author | Ilya Ryzhenkov <orangy@jetbrains.com> | 2014-07-11 20:49:04 +0400 |
---|---|---|
committer | Ilya Ryzhenkov <orangy@jetbrains.com> | 2014-07-11 20:49:04 +0400 |
commit | 044308ba60a0d4462ccb7388f16ad17a31d7450d (patch) | |
tree | c93411f0670e29fe333962789c0df97b1602f7be /src/Analysis/CommentsAPI.kt | |
parent | 8a4dad46b171c55dabc5f9be29e1261e1cc5928e (diff) | |
download | dokka-044308ba60a0d4462ccb7388f16ad17a31d7450d.tar.gz dokka-044308ba60a0d4462ccb7388f16ad17a31d7450d.tar.bz2 dokka-044308ba60a0d4462ccb7388f16ad17a31d7450d.zip |
Complete package migration and move files into folders.
Diffstat (limited to 'src/Analysis/CommentsAPI.kt')
-rw-r--r-- | src/Analysis/CommentsAPI.kt | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/Analysis/CommentsAPI.kt b/src/Analysis/CommentsAPI.kt new file mode 100644 index 00000000..a32ee734 --- /dev/null +++ b/src/Analysis/CommentsAPI.kt @@ -0,0 +1,30 @@ +package org.jetbrains.dokka + +import org.jetbrains.jet.lang.descriptors.* +import org.jetbrains.jet.lang.resolve.* +import org.jetbrains.jet.kdoc.psi.api.* +import org.jetbrains.jet.lang.psi.* + +fun BindingContext.getDocumentation(descriptor: DeclarationDescriptor): KDoc? { + val psiElement = DescriptorToSourceUtils.descriptorToDeclaration(descriptor) + if (psiElement == null) + throw IllegalArgumentException("$descriptor doesn't have connection to source code, is it synthetic?") + + 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 |