diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-03-06 16:11:32 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-03-06 16:11:32 +0100 |
commit | 8f159151f182f4561594a4c23c22e82830bcc9b4 (patch) | |
tree | 6b351f83ae3808bdcc93c6a9755f9139b184c36b /src | |
parent | 0cab60b604cd7f0f642ab389973bfce1bbbe6071 (diff) | |
download | dokka-8f159151f182f4561594a4c23c22e82830bcc9b4.tar.gz dokka-8f159151f182f4561594a4c23c22e82830bcc9b4.tar.bz2 dokka-8f159151f182f4561594a4c23c22e82830bcc9b4.zip |
generate documentation for default object extension properties
Diffstat (limited to 'src')
-rw-r--r-- | src/Formats/StructuredFormatService.kt | 2 | ||||
-rw-r--r-- | src/Kotlin/DocumentationBuilder.kt | 30 |
2 files changed, 27 insertions, 5 deletions
diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt index 7b9374ec..cc551eb4 100644 --- a/src/Formats/StructuredFormatService.kt +++ b/src/Formats/StructuredFormatService.kt @@ -306,6 +306,8 @@ public abstract class StructuredFormatService(locationService: LocationService, }, node, to) appendSection(location, "Extension Properties", node.extensions.filter { it.kind == DocumentationNode.Kind.Property }, node, to) appendSection(location, "Extension Functions", node.extensions.filter { it.kind == DocumentationNode.Kind.Function }, node, to) + appendSection(location, "Default Object Extension Properties", node.extensions.filter { it.kind == DocumentationNode.Kind.DefaultObjectProperty }, node, to) + appendSection(location, "Default Object Extension Functions", node.extensions.filter { it.kind == DocumentationNode.Kind.DefaultObjectFunction }, node, to) appendSection(location, "Inheritors", node.inheritors.filter { it.kind != DocumentationNode.Kind.EnumItem }, node, to) appendSection(location, "Links", node.links, node, to) diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt index 9ca3ad79..aa4a0caf 100644 --- a/src/Kotlin/DocumentationBuilder.kt +++ b/src/Kotlin/DocumentationBuilder.kt @@ -144,11 +144,12 @@ class DocumentationBuilder(val session: ResolveSession, } fun JetType.signature(): String { - val typeName = getConstructor().getDeclarationDescriptor()?.getName()?.asString() + val declarationDescriptor = getConstructor().getDeclarationDescriptor() ?: return "<null>" + val typeName = DescriptorUtils.getFqName(declarationDescriptor).asString() if (typeName == "Array" && getArguments().size() == 1) { return "Array<" + getArguments().first().getType().signature() + ">" } - return typeName ?: "<null>" + return typeName } fun resolveContentLink(descriptor: DeclarationDescriptor, href: String): ContentBlock { @@ -266,6 +267,15 @@ class DocumentationBuilder(val session: ResolveSession, return val classifierDescriptor = jetType.getConstructor().getDeclarationDescriptor() val name = when (classifierDescriptor) { + is ClassDescriptor -> { + if (classifierDescriptor.isDefaultObject()) { + classifierDescriptor.getContainingDeclaration().getName().asString() + + "." + classifierDescriptor.getName().asString() + } + else { + classifierDescriptor.getName().asString() + } + } is Named -> classifierDescriptor.getName().asString() else -> "<anonymous>" } @@ -428,8 +438,14 @@ class DocumentationBuilder(val session: ResolveSession, return node } - private fun DeclarationDescriptor.inDefaultObject() = - getContainingDeclaration().let { it is ClassDescriptor && it.isDefaultObject() } + private fun CallableMemberDescriptor.inDefaultObject(): Boolean { + val containingDeclaration = getContainingDeclaration() + if ((containingDeclaration as? ClassDescriptor)?.isDefaultObject() ?: false) { + return true + } + val receiver = getExtensionReceiverParameter() + return (receiver?.getType()?.getConstructor()?.getDeclarationDescriptor() as? ClassDescriptor)?.isDefaultObject() ?: false + } fun CallableMemberDescriptor.getExtensionClassDescriptor(): ClassifierDescriptor? { val extensionReceiver = getExtensionReceiverParameter() @@ -614,7 +630,11 @@ class DocumentationBuilder(val session: ResolveSession, } fun ReceiverParameterDescriptor.build(): DocumentationNode { - link(getType().getConstructor().getDeclarationDescriptor(), + var receiverClass: DeclarationDescriptor = getType().getConstructor().getDeclarationDescriptor() + if ((receiverClass as? ClassDescriptor)?.isDefaultObject() ?: false) { + receiverClass = receiverClass.getContainingDeclaration()!! + } + link(receiverClass, getContainingDeclaration(), DocumentationReference.Kind.Extension) |