diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-10-28 15:23:50 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-10-29 11:57:24 +0100 |
commit | 36f4b916bc956d8f5c9f6b55d295ea9a69c9f0bc (patch) | |
tree | cab9e34dec64cce5cea97bbf9f1bd5e276ac42be /src | |
parent | 78455025203b911c855f7cfc0d75270dd7351199 (diff) | |
download | dokka-36f4b916bc956d8f5c9f6b55d295ea9a69c9f0bc.tar.gz dokka-36f4b916bc956d8f5c9f6b55d295ea9a69c9f0bc.tar.bz2 dokka-36f4b916bc956d8f5c9f6b55d295ea9a69c9f0bc.zip |
show inherited members in the list of class members
Diffstat (limited to 'src')
-rw-r--r-- | src/Formats/StructuredFormatService.kt | 2 | ||||
-rw-r--r-- | src/Kotlin/DocumentationBuilder.kt | 21 | ||||
-rw-r--r-- | src/Model/DocumentationNode.kt | 3 | ||||
-rw-r--r-- | src/Model/DocumentationReference.kt | 1 |
4 files changed, 21 insertions, 6 deletions
diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt index 8473ccd5..8bc60826 100644 --- a/src/Formats/StructuredFormatService.kt +++ b/src/Formats/StructuredFormatService.kt @@ -314,7 +314,9 @@ public abstract class StructuredFormatService(locationService: LocationService, appendSection(location, "Extensions for External Classes", node.members(DocumentationNode.Kind.ExternalClass), node, to) appendSection(location, "Constructors", node.members(DocumentationNode.Kind.Constructor), node, to) appendSection(location, "Properties", node.members(DocumentationNode.Kind.Property), node, to) + appendSection(location, "Inherited Properties", node.inheritedMembers(DocumentationNode.Kind.Property), node, to) appendSection(location, "Functions", node.members(DocumentationNode.Kind.Function), node, to) + appendSection(location, "Inherited Functions", node.inheritedMembers(DocumentationNode.Kind.Function), node, to) appendSection(location, "Companion Object Properties", node.members(DocumentationNode.Kind.CompanionObjectProperty), node, to) appendSection(location, "Companion Object Functions", node.members(DocumentationNode.Kind.CompanionObjectFunction), node, to) appendSection(location, "Enum Values", node.members(DocumentationNode.Kind.EnumItem), node, to) diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt index ea54f4d3..08a74172 100644 --- a/src/Kotlin/DocumentationBuilder.kt +++ b/src/Kotlin/DocumentationBuilder.kt @@ -404,8 +404,18 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, } - fun DocumentationNode.appendChildren(descriptors: Iterable<DeclarationDescriptor>, kind: DocumentationReference.Kind) { - descriptors.forEach { descriptor -> appendChild(descriptor, kind) } + fun DocumentationNode.appendMembers(descriptors: Iterable<DeclarationDescriptor>) { + descriptors.forEach { descriptor -> + if (descriptor is CallableMemberDescriptor && descriptor.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) { + val baseDescriptor = descriptor.overriddenDescriptors.firstOrNull() + if (baseDescriptor != null) { + link(this, baseDescriptor, DocumentationReference.Kind.InheritedMember) + } + } + else { + appendChild(descriptor, DocumentationReference.Kind.Member) + } + } } fun DocumentationNode.appendInPageChildren(descriptors: Iterable<DeclarationDescriptor>, kind: DocumentationReference.Kind) { @@ -483,14 +493,13 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, constructors.filter { it.valueParameters.size > 0 } else constructors - node.appendChildren(constructorsToDocument, DocumentationReference.Kind.Member) + node.appendMembers(constructorsToDocument) } val members = defaultType.memberScope.getAllDescriptors().filter { it != companionObjectDescriptor } - node.appendChildren(members, DocumentationReference.Kind.Member) + node.appendMembers(members) val companionObjectDescriptor = companionObjectDescriptor if (companionObjectDescriptor != null) { - node.appendChildren(companionObjectDescriptor.defaultType.memberScope.getAllDescriptors(), - DocumentationReference.Kind.Member) + node.appendMembers(companionObjectDescriptor.defaultType.memberScope.getAllDescriptors()) } node.appendAnnotations(this) node.appendModifiers(this) diff --git a/src/Model/DocumentationNode.kt b/src/Model/DocumentationNode.kt index c082365f..6f6cee7e 100644 --- a/src/Model/DocumentationNode.kt +++ b/src/Model/DocumentationNode.kt @@ -19,6 +19,8 @@ public open class DocumentationNode(val name: String, get() = references(DocumentationReference.Kind.Detail).map { it.to } public val members: List<DocumentationNode> get() = references(DocumentationReference.Kind.Member).map { it.to } + public val inheritedMembers: List<DocumentationNode> + get() = references(DocumentationReference.Kind.InheritedMember).map { it.to } public val extensions: List<DocumentationNode> get() = references(DocumentationReference.Kind.Extension).map { it.to } public val inheritors: List<DocumentationNode> @@ -52,6 +54,7 @@ public open class DocumentationNode(val name: String, public fun details(kind: DocumentationNode.Kind): List<DocumentationNode> = details.filter { it.kind == kind } public fun members(kind: DocumentationNode.Kind): List<DocumentationNode> = members.filter { it.kind == kind } + public fun inheritedMembers(kind: DocumentationNode.Kind): List<DocumentationNode> = inheritedMembers.filter { it.kind == kind } public fun links(kind: DocumentationNode.Kind): List<DocumentationNode> = links.filter { it.kind == kind } public fun detail(kind: DocumentationNode.Kind): DocumentationNode = details.filter { it.kind == kind }.single() diff --git a/src/Model/DocumentationReference.kt b/src/Model/DocumentationReference.kt index bbdd026d..47b9a265 100644 --- a/src/Model/DocumentationReference.kt +++ b/src/Model/DocumentationReference.kt @@ -4,6 +4,7 @@ public data class DocumentationReference(val from: DocumentationNode, val to: Do public enum class Kind { Owner, Member, + InheritedMember, Detail, Link, HiddenLink, |