aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2015-01-14 13:30:43 +0100
committerDmitry Jemerov <yole@jetbrains.com>2015-01-14 13:30:43 +0100
commit0dd5ea3c1492b15bd386ec5c2c8d6e467a8f72a9 (patch)
tree0804f2730bd7da28cfb063f1b00fb4cc1773c4f9 /src
parentcd21e1fea43c0b7fa8013e3db7f49fe2b600b7f8 (diff)
downloaddokka-0dd5ea3c1492b15bd386ec5c2c8d6e467a8f72a9.tar.gz
dokka-0dd5ea3c1492b15bd386ec5c2c8d6e467a8f72a9.tar.bz2
dokka-0dd5ea3c1492b15bd386ec5c2c8d6e467a8f72a9.zip
link overriding functions to the corresponding base class functions
Diffstat (limited to 'src')
-rw-r--r--src/Formats/StructuredFormatService.kt34
-rw-r--r--src/Kotlin/DocumentationBuilder.kt23
-rw-r--r--src/Model/DocumentationNode.kt2
3 files changed, 48 insertions, 11 deletions
diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt
index 3f505e37..bfb69d1d 100644
--- a/src/Formats/StructuredFormatService.kt
+++ b/src/Formats/StructuredFormatService.kt
@@ -119,23 +119,35 @@ public abstract class StructuredFormatService(val locationService: LocationServi
for ((summary, items) in breakdownBySummary) {
items.forEach {
appendBlockCode(to, formatText(location, languageService.render(it)))
- val deprecation = it.deprecation
- if (deprecation != null) {
- val deprecationParameter = deprecation.details(DocumentationNode.Kind.Parameter).firstOrNull()
- val deprecationValue = deprecationParameter?.details(DocumentationNode.Kind.Value)?.firstOrNull()
- if (deprecationValue != null) {
- to.append(formatStrong("Deprecated: "))
- appendLine(to, formatText(deprecationValue.name.trim("\"")))
- } else {
- appendLine(to, formatStrong("Deprecated"))
- }
- }
+ it.appendOverrides(to)
+ it.appendDeprecation(to)
}
appendLine(to, summary)
appendLine(to)
}
}
+ private fun DocumentationNode.appendOverrides(to: StringBuilder) {
+ overrides.forEach {
+ to.append("Overrides ")
+ val location = locationService.relativeLocation(this, it, extension)
+ appendLine(to, formatLink(FormatLink(it.owner!!.name + "." + it.name, location)))
+ }
+ }
+
+ private fun DocumentationNode.appendDeprecation(to: StringBuilder) {
+ if (deprecation != null) {
+ val deprecationParameter = deprecation!!.details(DocumentationNode.Kind.Parameter).firstOrNull()
+ val deprecationValue = deprecationParameter?.details(DocumentationNode.Kind.Value)?.firstOrNull()
+ if (deprecationValue != null) {
+ to.append(formatStrong("Deprecated: "))
+ appendLine(to, formatText(deprecationValue.name.trim("\"")))
+ } else {
+ appendLine(to, formatStrong("Deprecated"))
+ }
+ }
+ }
+
fun appendLocation(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) {
val breakdownByName = nodes.groupBy { node -> node.name }
for ((name, items) in breakdownByName) {
diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt
index 892a462e..0b978370 100644
--- a/src/Kotlin/DocumentationBuilder.kt
+++ b/src/Kotlin/DocumentationBuilder.kt
@@ -412,6 +412,14 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati
}
}
+ val descriptor = nodeToDescriptor[node]
+ if (descriptor is FunctionDescriptor) {
+ val overrides = descriptor.getOverriddenDescriptors();
+ overrides?.forEach {
+ addOverrideLink(node, it)
+ }
+ }
+
resolveContentLinks(node, node.content)
for (child in node.members) {
@@ -422,6 +430,21 @@ class DocumentationBuilder(val session: ResolveSession, val options: Documentati
}
}
+ /**
+ * Add an override link from a function node to the node corresponding to the specified descriptor.
+ * Note that this descriptor may be contained in a class where the function is not actually overridden
+ * (just inherited from the parent), so we need to go further up the override chain to find a function
+ * which exists in the code and for which we do have a documentation node.
+ */
+ private fun addOverrideLink(node: DocumentationNode, overriddenDescriptor: FunctionDescriptor) {
+ val overriddenNode = descriptorToNode[overriddenDescriptor.getOriginal()]
+ if (overriddenNode != null) {
+ node.addReferenceTo(overriddenNode, DocumentationReference.Kind.Override)
+ } else {
+ overriddenDescriptor.getOverriddenDescriptors().forEach { addOverrideLink(node, it) }
+ }
+ }
+
fun getResolutionScope(node: DocumentationNode): DeclarationDescriptor {
val descriptor = nodeToDescriptor[node] ?: throw IllegalArgumentException("Node is not known to this context")
return descriptor
diff --git a/src/Model/DocumentationNode.kt b/src/Model/DocumentationNode.kt
index 635d1db9..6e707cce 100644
--- a/src/Model/DocumentationNode.kt
+++ b/src/Model/DocumentationNode.kt
@@ -28,6 +28,8 @@ public open class DocumentationNode(val name: String,
get() = references(DocumentationReference.Kind.Extension).map { it.to }
public val inheritors: List<DocumentationNode>
get() = references(DocumentationReference.Kind.Inheritor).map { it.to }
+ public val overrides: List<DocumentationNode>
+ get() = references(DocumentationReference.Kind.Override).map { it.to }
public val links: List<DocumentationNode>
get() = references(DocumentationReference.Kind.Link).map { it.to }
public val annotations: List<DocumentationNode>