diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-02-16 12:00:07 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-02-16 12:05:17 +0100 |
commit | c11ae71c3fdad03f1ba0624ca693b34782f1e6e9 (patch) | |
tree | 0e1e8bf34e45fe2c332f05c766f4b15a194a2c87 /src | |
parent | 902aeb158001473aa2d8d011c1e8e584163c5edd (diff) | |
download | dokka-c11ae71c3fdad03f1ba0624ca693b34782f1e6e9.tar.gz dokka-c11ae71c3fdad03f1ba0624ca693b34782f1e6e9.tar.bz2 dokka-c11ae71c3fdad03f1ba0624ca693b34782f1e6e9.zip |
convert doc tags to sections
Diffstat (limited to 'src')
-rw-r--r-- | src/Java/JavaDocumentationBuilder.kt | 18 | ||||
-rw-r--r-- | src/Kotlin/DocumentationBuilder.kt | 9 | ||||
-rw-r--r-- | src/Model/Content.kt | 7 |
3 files changed, 26 insertions, 8 deletions
diff --git a/src/Java/JavaDocumentationBuilder.kt b/src/Java/JavaDocumentationBuilder.kt index 0737e504..660ffafb 100644 --- a/src/Java/JavaDocumentationBuilder.kt +++ b/src/Java/JavaDocumentationBuilder.kt @@ -15,6 +15,8 @@ import com.intellij.psi.PsiModifierListOwner import com.intellij.psi.PsiModifier import com.intellij.psi.PsiArrayType import com.intellij.psi.PsiTypeParameter +import com.intellij.psi.javadoc.PsiDocTag +import com.intellij.psi.javadoc.PsiDocTagValue public class JavaDocumentationBuilder() { fun appendFile(file: PsiJavaFile, module: DocumentationModule) { @@ -29,9 +31,25 @@ public class JavaDocumentationBuilder() { val text = if (result.isEmpty()) it.getText().trimLeading() else it.getText() result.append(ContentText(text)) } + docComment.getTags().forEach { + val subjectName = it.getSubjectName() + val section = result.addSection(javadocSectionDisplayName(it.getName()), subjectName) + it.getDataElements().forEach { + if (it !is PsiDocTagValue) { + section.append(ContentText(it.getText())) + } + } + } return result } + fun PsiDocTag.getSubjectName(): String? { + if (getName() == "param") { + return getValueElement()?.getText() + } + return null + } + fun DocumentationNode(element: PsiNamedElement, kind: Kind, name: String = element.getName() ?: "<anonymous>"): DocumentationNode { diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt index 1ad1e9e8..775c959a 100644 --- a/src/Kotlin/DocumentationBuilder.kt +++ b/src/Kotlin/DocumentationBuilder.kt @@ -61,7 +61,7 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati "see" -> content.addTagToSeeAlso(it) else -> { - val section = content.addSection(displayName(it.getName()), it.getSubjectName()) + val section = content.addSection(javadocSectionDisplayName(it.getName()), it.getSubjectName()) val sectionContent = it.getContent() val markdownNode = parseMarkdown(sectionContent) buildInlineContentTo(markdownNode, section) @@ -74,13 +74,6 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati 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?.capitalize() - } - private fun Content.addTagToSeeAlso(seeTag: KDocTag) { val subjectName = seeTag.getSubjectName() if (subjectName != null) { diff --git a/src/Model/Content.kt b/src/Model/Content.kt index f74a4461..9864ee42 100644 --- a/src/Model/Content.kt +++ b/src/Model/Content.kt @@ -132,3 +132,10 @@ public class Content() : ContentBlock() { val Empty = Content() } } + +fun javadocSectionDisplayName(sectionName: String?): String? = + when(sectionName) { + "param" -> "Parameters" + "throws", "exception" -> "Exceptions" + else -> sectionName?.capitalize() + } |