From bfd9ffd13ed6b6916790f5f0de5f9523db71b22e Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 30 Jan 2015 17:59:15 +0100 Subject: load sections from KDoc PSI, not through Markdown extensions --- src/Analysis/CommentsAPI.kt | 41 ----------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 src/Analysis/CommentsAPI.kt (limited to 'src/Analysis/CommentsAPI.kt') diff --git a/src/Analysis/CommentsAPI.kt b/src/Analysis/CommentsAPI.kt deleted file mode 100644 index ce453113..00000000 --- a/src/Analysis/CommentsAPI.kt +++ /dev/null @@ -1,41 +0,0 @@ -package org.jetbrains.dokka - -import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.resolve.* -import org.jetbrains.kotlin.kdoc.psi.api.* - -/** - * Retrieves PSI elements representing documentation from the [DeclarationDescriptor] - * - * $$receiver: [DeclarationDescriptor] to get documentation nodes from - */ -fun DeclarationDescriptor.getDocumentationElements(): List { - val psiElement = DescriptorToSourceUtils.descriptorToDeclaration(this) - if (psiElement == null) - return listOf() - - return psiElement.children() // visit children - .takeWhile { it is KDoc } // all KDoc - .map { it as KDoc } // cast - .toList() - .reverse() // make reversed list -} - -/** - * Extracts text from KDoc, removes comment symbols and trims whitespace - */ -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 { - val comment = it.trim().dropWhile { it == '/' || it == '*' } - (if (comment.endsWith("*/")) - comment.substring(0, comment.length() - 2) - else - comment).trim() - }.join("\n").trim("\n") -} \ No newline at end of file -- cgit