diff options
author | Ilya Ryzhenkov <orangy@jetbrains.com> | 2014-10-03 15:57:16 +0400 |
---|---|---|
committer | Ilya Ryzhenkov <orangy@jetbrains.com> | 2014-10-03 15:57:16 +0400 |
commit | a52e1d543d22fdacf87ec00988b753d2d1107c1d (patch) | |
tree | 0b27f4aa91494d715044af79dead49c6e4f3fc00 /src/Kotlin/DocumentationNodeBuilder.kt | |
parent | e93b629e4b2fa70330d94b8cb77f3ae34d1a9960 (diff) | |
download | dokka-a52e1d543d22fdacf87ec00988b753d2d1107c1d.tar.gz dokka-a52e1d543d22fdacf87ec00988b753d2d1107c1d.tar.bz2 dokka-a52e1d543d22fdacf87ec00988b753d2d1107c1d.zip |
Work on cross-references.
Diffstat (limited to 'src/Kotlin/DocumentationNodeBuilder.kt')
-rw-r--r-- | src/Kotlin/DocumentationNodeBuilder.kt | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/Kotlin/DocumentationNodeBuilder.kt b/src/Kotlin/DocumentationNodeBuilder.kt index 535f037f..66f71bf6 100644 --- a/src/Kotlin/DocumentationNodeBuilder.kt +++ b/src/Kotlin/DocumentationNodeBuilder.kt @@ -21,10 +21,11 @@ class DocumentationNodeBuilder(val context: DocumentationContext) : DeclarationD fun reference(from: DocumentationNode, to: DocumentationNode, kind: DocumentationReference.Kind) { from.addReferenceTo(to, kind) - if (kind == DocumentationReference.Kind.Link) - to.addReferenceTo(from, DocumentationReference.Kind.Link) - else - to.addReferenceTo(from, DocumentationReference.Kind.Owner) + when (kind) { + DocumentationReference.Kind.Detail -> to.addReferenceTo(from, DocumentationReference.Kind.Owner) + DocumentationReference.Kind.Member -> to.addReferenceTo(from, DocumentationReference.Kind.Owner) + DocumentationReference.Kind.Owner -> to.addReferenceTo(from, DocumentationReference.Kind.Member) + } } fun addModality(descriptor: MemberDescriptor, data: DocumentationNode) { @@ -42,15 +43,16 @@ class DocumentationNodeBuilder(val context: DocumentationContext) : DeclarationD fun addType(descriptor: DeclarationDescriptor, t: JetType?, data: DocumentationNode) { if (t == null) return - val typeConstructor = t.getConstructor() - val classifierDescriptor = typeConstructor.getDeclarationDescriptor() + val classifierDescriptor = t.getConstructor().getDeclarationDescriptor() val name = when (classifierDescriptor) { is Named -> classifierDescriptor.getName().asString() else -> "<anonymous>" } val node = DocumentationNode(name, Content.Empty, DocumentationNode.Kind.Type) - reference(data, node, DocumentationReference.Kind.Detail) + if (classifierDescriptor != null) + context.attach(node, classifierDescriptor) + reference(data, node, DocumentationReference.Kind.Detail) for (param in t.getArguments()) addType(descriptor, param.getType(), node) } @@ -59,7 +61,7 @@ class DocumentationNodeBuilder(val context: DocumentationContext) : DeclarationD descriptor!! val doc = context.parseDocumentation(descriptor) val node = DocumentationNode(descriptor.getName().asString(), doc, DocumentationNode.Kind.Unknown) - reference(data!!, node, DocumentationReference.Kind.Link) + reference(data!!, node, DocumentationReference.Kind.Member) context.register(descriptor, node) return node } |