aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2014-12-30 16:59:34 +0100
committerDmitry Jemerov <yole@jetbrains.com>2014-12-30 16:59:34 +0100
commit0e70fa4ca021bff09e7d9ce64269a4e698512af5 (patch)
tree48baff7faa1955ff60fed060a531982da33f36f6
parentef51f7e2466e28db0943d528b6b489aefd098c0d (diff)
downloaddokka-0e70fa4ca021bff09e7d9ce64269a4e698512af5.tar.gz
dokka-0e70fa4ca021bff09e7d9ce64269a4e698512af5.tar.bz2
dokka-0e70fa4ca021bff09e7d9ce64269a4e698512af5.zip
render annotations
-rw-r--r--src/Kotlin/KotlinLanguageService.kt24
-rw-r--r--test/data/format/annotations.kt4
-rw-r--r--test/data/format/annotations.md30
-rw-r--r--test/src/format/MarkdownFormatTest.kt2
-rw-r--r--test/src/model/ClassTest.kt1
5 files changed, 49 insertions, 12 deletions
diff --git a/src/Kotlin/KotlinLanguageService.kt b/src/Kotlin/KotlinLanguageService.kt
index a4016849..1e5edf4d 100644
--- a/src/Kotlin/KotlinLanguageService.kt
+++ b/src/Kotlin/KotlinLanguageService.kt
@@ -1,15 +1,6 @@
package org.jetbrains.dokka
-import org.jetbrains.dokka.symbol
-import org.jetbrains.dokka.text
-import org.jetbrains.dokka.identifier
-import org.jetbrains.dokka.link
-import org.jetbrains.dokka.keyword
-import org.jetbrains.dokka.LanguageService
-import org.jetbrains.dokka.DocumentationNode
-import org.jetbrains.dokka.ContentNode
import org.jetbrains.dokka
-import org.jetbrains.dokka.ContentText
/**
* Implements [LanguageService] and provides rendering of symbols in Kotlin language
@@ -135,6 +126,7 @@ class KotlinLanguageService : LanguageService {
}
private fun ContentNode.renderParameter(node: DocumentationNode) {
+ renderAnnotationsForNode(node)
identifier(node.name)
symbol(": ")
val parameterType = node.detail(DocumentationNode.Kind.Type)
@@ -171,8 +163,20 @@ class KotlinLanguageService : LanguageService {
}
}
+ private fun ContentNode.renderAnnotationsForNode(node: DocumentationNode) {
+ node.annotations.forEach {
+ renderAnnotation(it)
+ }
+ }
+
+ private fun ContentNode.renderAnnotation(node: DocumentationNode) {
+ identifier(node.name)
+ text(" ")
+ }
+
private fun ContentNode.renderClass(node: DocumentationNode) {
renderModifiersForNode(node)
+ renderAnnotationsForNode(node)
when (node.kind) {
DocumentationNode.Kind.Class -> keyword("class ")
DocumentationNode.Kind.Interface -> keyword("trait ")
@@ -189,6 +193,7 @@ class KotlinLanguageService : LanguageService {
private fun ContentNode.renderFunction(node: DocumentationNode) {
renderModifiersForNode(node)
+ renderAnnotationsForNode(node)
when (node.kind) {
DocumentationNode.Kind.Constructor -> identifier(node.owner!!.name)
DocumentationNode.Kind.Function,
@@ -218,6 +223,7 @@ class KotlinLanguageService : LanguageService {
private fun ContentNode.renderProperty(node: DocumentationNode) {
renderModifiersForNode(node)
+ renderAnnotationsForNode(node)
when (node.kind) {
DocumentationNode.Kind.Property,
DocumentationNode.Kind.ClassObjectProperty -> keyword("val ")
diff --git a/test/data/format/annotations.kt b/test/data/format/annotations.kt
index 445ec969..9356d4ca 100644
--- a/test/data/format/annotations.kt
+++ b/test/data/format/annotations.kt
@@ -1,4 +1,6 @@
data class Foo {
- inline fun bar() {
+ inline fun bar([noinline] notInlined: () -> Unit) {
}
+
+ inline val x: Int
}
diff --git a/test/data/format/annotations.md b/test/data/format/annotations.md
index e69de29b..83f79397 100644
--- a/test/data/format/annotations.md
+++ b/test/data/format/annotations.md
@@ -0,0 +1,30 @@
+[test](out.md) / [](out.md) / [Foo](out.md)
+
+
+# Foo
+
+
+```
+data class Foo
+```
+
+
+
+
+### Constructors
+
+
+| [&lt;init&gt;](out.md) | `public Foo()` |
+
+
+### Properties
+
+
+| [x](out.md) | `inline val x: Int` |
+
+
+### Functions
+
+
+| [bar](out.md) | `inline fun bar(noinline notInlined: () -&gt; Unit): Unit` |
+
diff --git a/test/src/format/MarkdownFormatTest.kt b/test/src/format/MarkdownFormatTest.kt
index e9852964..531980de 100644
--- a/test/src/format/MarkdownFormatTest.kt
+++ b/test/src/format/MarkdownFormatTest.kt
@@ -21,7 +21,7 @@ public class MarkdownFormatTest {
}
Test fun annotations() {
- verifyOutput("test/data/format/annotations.kt") { model, output ->
+ verifyOutput("test/data/format/annotations.kt", ".md") { model, output ->
markdownService.appendNodes(tempLocation, output, model.members.single().members)
}
}
diff --git a/test/src/model/ClassTest.kt b/test/src/model/ClassTest.kt
index b9be30bf..257d73eb 100644
--- a/test/src/model/ClassTest.kt
+++ b/test/src/model/ClassTest.kt
@@ -166,7 +166,6 @@ public class ClassTest {
}
}
}
-}
Test fun annotatedClass() {
verifyModel("test/data/classes/annotatedClass.kt") { model ->