aboutsummaryrefslogtreecommitdiff
path: root/src/Kotlin
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2015-01-14 19:38:58 +0100
committerDmitry Jemerov <yole@jetbrains.com>2015-01-14 19:38:58 +0100
commitf36d9b0e4f336de7e35dcfa33934ab287b76d964 (patch)
tree9beb706729788f4126f1270c4abfe3e0bcb71481 /src/Kotlin
parent60e610ebdd86663bedf113d2235ac3c8364171d0 (diff)
downloaddokka-f36d9b0e4f336de7e35dcfa33934ab287b76d964.tar.gz
dokka-f36d9b0e4f336de7e35dcfa33934ab287b76d964.tar.bz2
dokka-f36d9b0e4f336de7e35dcfa33934ab287b76d964.zip
show default values of parameters in generated documentation
Diffstat (limited to 'src/Kotlin')
-rw-r--r--src/Kotlin/DocumentationBuilder.kt11
-rw-r--r--src/Kotlin/KotlinLanguageService.kt5
2 files changed, 16 insertions, 0 deletions
diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt
index 0b978370..5af4c9f1 100644
--- a/src/Kotlin/DocumentationBuilder.kt
+++ b/src/Kotlin/DocumentationBuilder.kt
@@ -12,6 +12,8 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant
import com.intellij.openapi.util.text.StringUtil
import org.jetbrains.kotlin.descriptors.impl.EnumEntrySyntheticClassDescriptor
+import org.jetbrains.kotlin.resolve.source.getPsi
+import org.jetbrains.kotlin.psi.JetParameter
public data class DocumentationOptions(val includeNonPublic: Boolean = false)
@@ -307,6 +309,15 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati
} else {
node.appendType(getType())
}
+ if (hasDefaultValue()) {
+ val psi = getSource().getPsi() as? JetParameter
+ if (psi != null) {
+ val defaultValueText = psi.getDefaultValue()?.getText()
+ if (defaultValueText != null) {
+ node.append(DocumentationNode(defaultValueText, Content.Empty, Kind.Value), DocumentationReference.Kind.Detail)
+ }
+ }
+ }
node.appendAnnotations(this)
register(this, node)
return node
diff --git a/src/Kotlin/KotlinLanguageService.kt b/src/Kotlin/KotlinLanguageService.kt
index 8795aba6..3e9192c4 100644
--- a/src/Kotlin/KotlinLanguageService.kt
+++ b/src/Kotlin/KotlinLanguageService.kt
@@ -133,6 +133,11 @@ class KotlinLanguageService : LanguageService {
symbol(": ")
val parameterType = node.detail(DocumentationNode.Kind.Type)
renderType(parameterType)
+ val valueNode = node.details(DocumentationNode.Kind.Value).firstOrNull()
+ if (valueNode != null) {
+ symbol(" = ")
+ text(valueNode.name)
+ }
}
private fun ContentNode.renderTypeParametersForNode(node: DocumentationNode) {