diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-02-16 15:43:59 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-02-16 15:43:59 +0100 |
commit | 107ef426ad6163d9a97177e6b8d51cd2291f6daf (patch) | |
tree | d8a1ad87c0dc0dd1abcdae9ae0df077aba8544b5 /src/Java/JavaDocumentationBuilder.kt | |
parent | 5c709d949d5497e562048b2731ab1c25cc06f386 (diff) | |
download | dokka-107ef426ad6163d9a97177e6b8d51cd2291f6daf.tar.gz dokka-107ef426ad6163d9a97177e6b8d51cd2291f6daf.tar.bz2 dokka-107ef426ad6163d9a97177e6b8d51cd2291f6daf.zip |
represent Java annotations in dokka
Diffstat (limited to 'src/Java/JavaDocumentationBuilder.kt')
-rw-r--r-- | src/Java/JavaDocumentationBuilder.kt | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Java/JavaDocumentationBuilder.kt b/src/Java/JavaDocumentationBuilder.kt index 5f0798dd..f1a9c520 100644 --- a/src/Java/JavaDocumentationBuilder.kt +++ b/src/Java/JavaDocumentationBuilder.kt @@ -19,6 +19,7 @@ import com.intellij.psi.javadoc.PsiDocTag import com.intellij.psi.javadoc.PsiDocTagValue import com.intellij.psi.PsiEllipsisType import com.intellij.psi.PsiField +import com.intellij.psi.PsiAnnotation public class JavaDocumentationBuilder(private val options: DocumentationOptions) { fun appendFile(file: PsiJavaFile, module: DocumentationModule) { @@ -59,6 +60,10 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions) val node = DocumentationNode(name, docComment, kind) if (element is PsiModifierListOwner) { node.appendModifiers(element) + val modifierList = element.getModifierList() + if (modifierList != null) { + node.appendChildren(modifierList.getAnnotations(), DocumentationReference.Kind.Annotation) { build() } + } } return node } @@ -186,4 +191,18 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions) is PsiArrayType -> "Array" else -> psiType.getCanonicalText() } + + fun PsiAnnotation.build(): DocumentationNode { + val node = DocumentationNode(getNameReferenceElement()?.getText() ?: "<?>", Content.Empty, DocumentationNode.Kind.Annotation) + getParameterList().getAttributes().forEach { + val parameter = DocumentationNode(it.getName() ?: "value", Content.Empty, DocumentationNode.Kind.Parameter) + val value = it.getValue() + if (value != null) { + val valueNode = DocumentationNode(value.getText(), Content.Empty, DocumentationNode.Kind.Value) + parameter.append(valueNode, DocumentationReference.Kind.Detail) + } + node.append(parameter, DocumentationReference.Kind.Detail) + } + return node + } } |