aboutsummaryrefslogtreecommitdiff
path: root/src/Kotlin/KotlinLanguageService.kt
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2015-02-26 16:28:05 +0100
committerDmitry Jemerov <yole@jetbrains.com>2015-02-26 16:28:05 +0100
commit722c9afcdf43e27ae82b30f8b21a6d0f967a7ee2 (patch)
treea288873000fc05263aca10a74182afa6c795a3c4 /src/Kotlin/KotlinLanguageService.kt
parent6714d6574a14200175d1d3db903e50ef4267aaf7 (diff)
downloaddokka-722c9afcdf43e27ae82b30f8b21a6d0f967a7ee2.tar.gz
dokka-722c9afcdf43e27ae82b30f8b21a6d0f967a7ee2.tar.bz2
dokka-722c9afcdf43e27ae82b30f8b21a6d0f967a7ee2.zip
use non-breaking spaces when generating signatures
Diffstat (limited to 'src/Kotlin/KotlinLanguageService.kt')
-rw-r--r--src/Kotlin/KotlinLanguageService.kt41
1 files changed, 27 insertions, 14 deletions
diff --git a/src/Kotlin/KotlinLanguageService.kt b/src/Kotlin/KotlinLanguageService.kt
index 56baad58..435fbc64 100644
--- a/src/Kotlin/KotlinLanguageService.kt
+++ b/src/Kotlin/KotlinLanguageService.kt
@@ -48,12 +48,18 @@ class KotlinLanguageService : LanguageService {
identifier(node.name)
}
- private fun ContentBlock.renderList(nodes: List<DocumentationNode>, separator: String = ", ", renderItem: (DocumentationNode) -> Unit) {
+ private fun ContentBlock.renderList(nodes: List<DocumentationNode>, separator: String = ", ",
+ noWrap: Boolean = false, renderItem: (DocumentationNode) -> Unit) {
if (nodes.none())
return
renderItem(nodes.first())
nodes.drop(1).forEach {
- symbol(separator)
+ if (noWrap) {
+ symbol(separator.trimTrailing(" "))
+ nbsp()
+ } else {
+ symbol(separator)
+ }
renderItem(it)
}
}
@@ -73,13 +79,13 @@ class KotlinLanguageService : LanguageService {
if (node.name == "Function${typeArguments.count() - 1}") {
// lambda
symbol("(")
- renderList(typeArguments.take(typeArguments.size - 1)) {
+ renderList(typeArguments.take(typeArguments.size() - 1), noWrap = true) {
renderType(it)
}
symbol(")")
- text(" ")
+ nbsp()
symbol("->")
- text(" ")
+ nbsp()
renderType(typeArguments.last())
return
}
@@ -88,20 +94,20 @@ class KotlinLanguageService : LanguageService {
renderType(typeArguments.first())
symbol(".")
symbol("(")
- renderList(typeArguments.drop(1).take(typeArguments.size - 2)) {
+ renderList(typeArguments.drop(1).take(typeArguments.size() - 2), noWrap = true) {
renderType(it)
}
symbol(")")
- text(" ")
+ nbsp()
symbol("->")
- text(" ")
+ nbsp()
renderType(typeArguments.last())
return
}
renderLinked(node) { identifier(it.name) }
if (typeArguments.any()) {
symbol("<")
- renderList(typeArguments) {
+ renderList(typeArguments, noWrap = true) {
renderType(it)
}
symbol(">")
@@ -122,8 +128,10 @@ class KotlinLanguageService : LanguageService {
val constraints = node.details(DocumentationNode.Kind.UpperBound)
identifier(node.name)
if (constraints.any()) {
- symbol(" : ")
- renderList(constraints) {
+ nbsp()
+ symbol(":")
+ nbsp()
+ renderList(constraints, noWrap=true) {
renderType(it)
}
}
@@ -132,12 +140,15 @@ class KotlinLanguageService : LanguageService {
private fun ContentBlock.renderParameter(node: DocumentationNode) {
renderAnnotationsForNode(node)
identifier(node.name)
- symbol(": ")
+ symbol(":")
+ nbsp()
val parameterType = node.detail(DocumentationNode.Kind.Type)
renderType(parameterType)
val valueNode = node.details(DocumentationNode.Kind.Value).firstOrNull()
if (valueNode != null) {
- symbol(" = ")
+ nbsp()
+ symbol("=")
+ nbsp()
text(valueNode.name)
}
}
@@ -156,7 +167,9 @@ class KotlinLanguageService : LanguageService {
private fun ContentBlock.renderSupertypesForNode(node: DocumentationNode) {
val supertypes = node.details(DocumentationNode.Kind.Supertype)
if (supertypes.any()) {
- symbol(" : ")
+ nbsp()
+ symbol(":")
+ nbsp()
renderList(supertypes) {
renderType(it)
}