aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIlya Ryzhenkov <orangy@jetbrains.com>2014-07-12 17:38:16 +0400
committerIlya Ryzhenkov <orangy@jetbrains.com>2014-07-12 17:38:16 +0400
commita77f01b4308945e44d05e7e05dc242512e5132eb (patch)
treefdb131cfb0005844df95b0765285e5cbdc1ca614 /src
parent1da7b0d28cc101c58e58b4ba00a7ed5890df34f5 (diff)
downloaddokka-a77f01b4308945e44d05e7e05dc242512e5132eb.tar.gz
dokka-a77f01b4308945e44d05e7e05dc242512e5132eb.tar.bz2
dokka-a77f01b4308945e44d05e7e05dc242512e5132eb.zip
Process Modality (final, open, abstract) and Visibility (public, protected, internal, private)
Diffstat (limited to 'src')
-rw-r--r--src/Model/DocumentationNode.kt2
-rw-r--r--src/Model/DocumentationNodeBuilder.kt72
-rw-r--r--src/main.kt2
3 files changed, 50 insertions, 26 deletions
diff --git a/src/Model/DocumentationNode.kt b/src/Model/DocumentationNode.kt
index ad1c3d57..ccfb9b7d 100644
--- a/src/Model/DocumentationNode.kt
+++ b/src/Model/DocumentationNode.kt
@@ -64,6 +64,8 @@ public open class DocumentationNode(val descriptor: DeclarationDescriptor,
LowerBound
Exception
+ Modifier
+
Module
}
diff --git a/src/Model/DocumentationNodeBuilder.kt b/src/Model/DocumentationNodeBuilder.kt
index 60f9ca0d..1f553f33 100644
--- a/src/Model/DocumentationNodeBuilder.kt
+++ b/src/Model/DocumentationNodeBuilder.kt
@@ -1,41 +1,59 @@
package org.jetbrains.dokka
import org.jetbrains.jet.lang.resolve.*
-import org.jetbrains.jet.lang.psi.*
import org.jetbrains.jet.lang.descriptors.*
import org.jetbrains.jet.lang.descriptors.impl.*
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
class DocumentationNodeBuilder(val context: BindingContext) : DeclarationDescriptorVisitorEmptyBodies<DocumentationNode, DocumentationNode>() {
+ 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)
+ }
+
+ fun addModality(descriptor: MemberDescriptor, data: DocumentationNode): DocumentationNode {
+ val modifier = descriptor.getModality().name().toLowerCase()
+ val node = DocumentationNode(descriptor, modifier, DocumentationContent.Empty, DocumentationNode.Kind.Modifier)
+ reference(data, node, DocumentationReference.Kind.Detail)
+ return node
+ }
+
+ fun addVisibility(descriptor: MemberDescriptor, data: DocumentationNode): DocumentationNode {
+ val modifier = descriptor.getVisibility().toString()
+ val node = DocumentationNode(descriptor, modifier, DocumentationContent.Empty, DocumentationNode.Kind.Modifier)
+ reference(data, node, DocumentationReference.Kind.Detail)
+ return node
+ }
+
override fun visitDeclarationDescriptor(descriptor: DeclarationDescriptor?, data: DocumentationNode?): DocumentationNode? {
val doc = context.getDocumentation(descriptor!!)
val node = DocumentationNode(descriptor, descriptor.getName().asString(), doc, DocumentationNode.Kind.Unknown)
- data!!.addReferenceTo(node, DocumentationReference.Kind.Link)
- node.addReferenceTo(data, DocumentationReference.Kind.Owner)
+ reference(data!!, node, DocumentationReference.Kind.Link)
return node
}
override fun visitReceiverParameterDescriptor(descriptor: ReceiverParameterDescriptor?, data: DocumentationNode?): DocumentationNode? {
val node = DocumentationNode(descriptor!!, descriptor.getName().asString(), DocumentationContent.Empty, DocumentationNode.Kind.Receiver)
- data!!.addReferenceTo(node, DocumentationReference.Kind.Detail)
+ reference(data!!, node, DocumentationReference.Kind.Detail)
val typeNode = DocumentationNode(descriptor, descriptor.getType().toString(), DocumentationContent.Empty, DocumentationNode.Kind.Type)
- node.addReferenceTo(typeNode, DocumentationReference.Kind.Detail)
+ reference(node, typeNode, DocumentationReference.Kind.Detail)
- node.addReferenceTo(data, DocumentationReference.Kind.Owner)
return node
}
override fun visitValueParameterDescriptor(descriptor: ValueParameterDescriptor?, data: DocumentationNode?): DocumentationNode? {
val doc = context.getDocumentation(descriptor!!)
val node = DocumentationNode(descriptor, descriptor.getName().asString(), doc, DocumentationNode.Kind.Parameter)
- data!!.addReferenceTo(node, DocumentationReference.Kind.Detail)
+ reference(data!!, node, DocumentationReference.Kind.Detail)
val typeNode = DocumentationNode(descriptor, descriptor.getType().toString(), DocumentationContent.Empty, DocumentationNode.Kind.Type)
- node.addReferenceTo(typeNode, DocumentationReference.Kind.Detail)
+ reference(node, typeNode, DocumentationReference.Kind.Detail)
- node.addReferenceTo(data, DocumentationReference.Kind.Owner)
return node
}
@@ -46,68 +64,72 @@ class DocumentationNodeBuilder(val context: BindingContext) : DeclarationDescrip
ClassKind.TRAIT -> DocumentationNode.Kind.Interface
else -> DocumentationNode.Kind.Class
})
- data!!.addReferenceTo(node, DocumentationReference.Kind.Member)
- node.addReferenceTo(data, DocumentationReference.Kind.Owner)
+ reference(data!!, node, DocumentationReference.Kind.Member)
+ addModality(descriptor, node)
+ addVisibility(descriptor, node)
return node
}
override fun visitFunctionDescriptor(descriptor: FunctionDescriptor?, data: DocumentationNode?): DocumentationNode? {
val doc = context.getDocumentation(descriptor!!)
val node = DocumentationNode(descriptor, descriptor.getName().asString(), doc, DocumentationNode.Kind.Function)
- data!!.addReferenceTo(node, DocumentationReference.Kind.Member)
+ reference(data!!, node, DocumentationReference.Kind.Member)
val typeNode = DocumentationNode(descriptor, descriptor.getReturnType().toString(), DocumentationContent.Empty, DocumentationNode.Kind.Type)
- node.addReferenceTo(typeNode, DocumentationReference.Kind.Detail)
+ reference(node, typeNode, DocumentationReference.Kind.Detail)
+
+ addModality(descriptor, node)
+ addVisibility(descriptor, node)
- node.addReferenceTo(data, DocumentationReference.Kind.Owner)
return node
}
override fun visitTypeParameterDescriptor(descriptor: TypeParameterDescriptor?, data: DocumentationNode?): DocumentationNode? {
val doc = context.getDocumentation(descriptor!!)
val node = DocumentationNode(descriptor, descriptor.getName().asString(), doc, DocumentationNode.Kind.TypeParameter)
- data!!.addReferenceTo(node, DocumentationReference.Kind.Detail)
+ reference(data!!, node, DocumentationReference.Kind.Detail)
val builtIns = KotlinBuiltIns.getInstance()
for (constraint in descriptor.getUpperBounds()) {
if (constraint == builtIns.getDefaultBound())
continue
val constraintNode = DocumentationNode(descriptor, constraint.toString(), DocumentationContent.Empty, DocumentationNode.Kind.UpperBound)
- node.addReferenceTo(constraintNode, DocumentationReference.Kind.Detail)
+ reference(node, constraintNode, DocumentationReference.Kind.Detail)
}
for (constraint in descriptor.getLowerBounds()) {
if (builtIns.isNothing(constraint))
continue
val constraintNode = DocumentationNode(descriptor, constraint.toString(), DocumentationContent.Empty, DocumentationNode.Kind.LowerBound)
- node.addReferenceTo(constraintNode, DocumentationReference.Kind.Detail)
+ reference(node, constraintNode, DocumentationReference.Kind.Detail)
}
- node.addReferenceTo(data, DocumentationReference.Kind.Owner)
return node
}
override fun visitPropertyDescriptor(descriptor: PropertyDescriptor?, data: DocumentationNode?): DocumentationNode? {
val doc = context.getDocumentation(descriptor!!)
val node = DocumentationNode(descriptor, descriptor.getName().asString(), doc, DocumentationNode.Kind.Property)
- data!!.addReferenceTo(node, DocumentationReference.Kind.Member)
+ reference(data!!, node, DocumentationReference.Kind.Member)
val typeNode = DocumentationNode(descriptor, descriptor.getType().toString(), DocumentationContent.Empty, DocumentationNode.Kind.Type)
- node.addReferenceTo(typeNode, DocumentationReference.Kind.Detail)
+ reference(node, typeNode, DocumentationReference.Kind.Detail)
- node.addReferenceTo(data, DocumentationReference.Kind.Owner)
+ addModality(descriptor, node)
+ addVisibility(descriptor, node)
return node
}
override fun visitConstructorDescriptor(descriptor: ConstructorDescriptor?, data: DocumentationNode?): DocumentationNode? {
val doc = context.getDocumentation(descriptor!!)
val node = DocumentationNode(descriptor, descriptor.getName().asString(), doc, DocumentationNode.Kind.Constructor)
- data!!.addReferenceTo(node, DocumentationReference.Kind.Member)
- node.addReferenceTo(data, DocumentationReference.Kind.Owner)
+ reference(data!!, node, DocumentationReference.Kind.Member)
+
+ addVisibility(descriptor, node)
+
return node
}
override fun visitPackageFragmentDescriptor(descriptor: PackageFragmentDescriptor?, data: DocumentationNode?): DocumentationNode? {
val node = DocumentationNode(descriptor!!, descriptor.fqName.asString(), DocumentationContent.Empty, DocumentationNode.Kind.Package)
- data!!.addReferenceTo(node, DocumentationReference.Kind.Member)
- node.addReferenceTo(data, DocumentationReference.Kind.Owner)
+ reference(data!!, node, DocumentationReference.Kind.Member)
return node
}
}
diff --git a/src/main.kt b/src/main.kt
index 6e1ef834..0faa357b 100644
--- a/src/main.kt
+++ b/src/main.kt
@@ -41,7 +41,7 @@ public fun main(args: Array<String>) {
context.createDocumentationModule(module, file)
}.reduce {(aggregate, item) -> aggregate.merge(item) }
- ConsoleGenerator(JavaSignatureGenerator()).generate(documentation)
+ ConsoleGenerator(KotlinSignatureGenerator()).generate(documentation)
Disposer.dispose(environment)
} \ No newline at end of file