aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2017-12-15 22:05:21 +0300
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2018-07-13 18:27:14 +0300
commit63ab561b66974c52a7d13e0823bf94329c0cd7f7 (patch)
treea4d53f4f2676463d30ff64cfa77329887951fcf8 /core
parent59069606904d297a5b4c9a8a95ad88eb30f7fd4f (diff)
downloaddokka-63ab561b66974c52a7d13e0823bf94329c0cd7f7.tar.gz
dokka-63ab561b66974c52a7d13e0823bf94329c0cd7f7.tar.bz2
dokka-63ab561b66974c52a7d13e0823bf94329c0cd7f7.zip
[backport] Make possible to generate signatures on output format side
Original: 4469044
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/Kotlin/DocumentationBuilder.kt1
-rw-r--r--core/src/main/kotlin/Kotlin/KotlinLanguageService.kt28
-rw-r--r--core/src/main/kotlin/Model/DocumentationNode.kt1
3 files changed, 17 insertions, 13 deletions
diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
index 7b50fff5..99d4d888 100644
--- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
+++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
@@ -234,6 +234,7 @@ class DocumentationBuilder
val externalLink = linkResolver.externalDocumentationLinkResolver.buildExternalDocumentationLink(classifierDescriptor)
if (externalLink != null) {
node.append(DocumentationNode(externalLink, Content.Empty, NodeKind.ExternalLink), RefKind.Link)
+ node.append(DocumentationNode(classifierDescriptor.fqNameUnsafe.asString(), Content.Empty, NodeKind.QualifiedName), RefKind.Detail)
} else {
link(node, classifierDescriptor,
if (classifierDescriptor.isBoringBuiltinClass()) RefKind.HiddenLink else RefKind.Link)
diff --git a/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt b/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
index 708facdb..b6f44716 100644
--- a/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
+++ b/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
@@ -48,8 +48,7 @@ class KotlinLanguageService : LanguageService {
val typeParameter = functionWithTypeParameter.details(NodeKind.TypeParameter).first()
if (functionWithTypeParameter.kind == NodeKind.Function) {
renderFunction(functionWithTypeParameter, RenderMode.SUMMARY, SummarizingMapper(receiverKind, typeParameter.name))
- }
- else {
+ } else {
renderProperty(functionWithTypeParameter, RenderMode.SUMMARY, SummarizingMapper(receiverKind, typeParameter.name))
}
}
@@ -103,7 +102,7 @@ class KotlinLanguageService : LanguageService {
fun renderReceiver(receiver: DocumentationNode, to: ContentBlock)
}
- private class SummarizingMapper(val kind: ReceiverKind, val typeParameterName: String): SignatureMapper {
+ private class SummarizingMapper(val kind: ReceiverKind, val typeParameterName: String) : SignatureMapper {
override fun renderReceiver(receiver: DocumentationNode, to: ContentBlock) {
to.append(ContentIdentifier(kind.receiverName, IdentifierKind.SummarizedTypeName))
to.text("<$typeParameterName>")
@@ -117,7 +116,7 @@ class KotlinLanguageService : LanguageService {
}
private fun <T> ContentBlock.renderList(nodes: List<T>, separator: String = ", ",
- noWrap: Boolean = false, renderItem: (T) -> Unit) {
+ noWrap: Boolean = false, renderItem: (T) -> Unit) {
if (nodes.none())
return
renderItem(nodes.first())
@@ -132,7 +131,7 @@ class KotlinLanguageService : LanguageService {
}
}
- private fun ContentBlock.renderLinked(node: DocumentationNode, body: ContentBlock.(DocumentationNode)->Unit) {
+ private fun ContentBlock.renderLinked(node: DocumentationNode, body: ContentBlock.(DocumentationNode) -> Unit) {
val to = node.links.firstOrNull()
if (to == null)
body(node)
@@ -216,13 +215,13 @@ class KotlinLanguageService : LanguageService {
private fun ContentBlock.renderModifier(node: DocumentationNode, nowrap: Boolean = false) {
when (node.name) {
- "final", "public", "var" -> {}
+ "final", "public", "var" -> {
+ }
else -> {
keyword(node.name)
if (nowrap) {
nbsp()
- }
- else {
+ } else {
text(" ")
}
}
@@ -239,11 +238,12 @@ class KotlinLanguageService : LanguageService {
nbsp()
symbol(":")
nbsp()
- renderList(constraints, noWrap=true) {
+ renderList(constraints, noWrap = true) {
renderType(it, renderMode)
}
}
}
+
private fun ContentBlock.renderParameter(node: DocumentationNode, renderMode: RenderMode) {
if (renderMode == RenderMode.FULL) {
renderAnnotationsForNode(node)
@@ -402,8 +402,7 @@ class KotlinLanguageService : LanguageService {
symbol(")")
symbol(": ")
renderType(node.detail(NodeKind.Type), renderMode)
- }
- else {
+ } else {
symbol(")")
}
renderExtraTypeParameterConstraints(node, renderMode)
@@ -429,7 +428,7 @@ class KotlinLanguageService : LanguageService {
}
}
- private fun needReturnType(node: DocumentationNode) = when(node.kind) {
+ private fun needReturnType(node: DocumentationNode) = when (node.kind) {
NodeKind.Constructor -> false
else -> !node.isUnitReturnType()
}
@@ -476,4 +475,7 @@ class KotlinLanguageService : LanguageService {
}
}
-fun DocumentationNode.qualifiedNameFromType() = (links.firstOrNull() ?: hiddenLinks.firstOrNull())?.qualifiedName() ?: name
+fun DocumentationNode.qualifiedNameFromType() =
+ details.firstOrNull { it.kind == NodeKind.QualifiedName }?.name
+ ?: (links.firstOrNull() ?: hiddenLinks.firstOrNull())?.qualifiedName()
+ ?: name
diff --git a/core/src/main/kotlin/Model/DocumentationNode.kt b/core/src/main/kotlin/Model/DocumentationNode.kt
index 897e3ad3..4b108798 100644
--- a/core/src/main/kotlin/Model/DocumentationNode.kt
+++ b/core/src/main/kotlin/Model/DocumentationNode.kt
@@ -48,6 +48,7 @@ enum class NodeKind {
Signature,
ExternalLink,
+ QualifiedName,
Platform,
AllTypes,