aboutsummaryrefslogtreecommitdiff
path: root/src/DocumentationBuilder.kt
diff options
context:
space:
mode:
authorIlya Ryzhenkov <orangy@jetbrains.com>2014-07-11 19:23:45 +0400
committerIlya Ryzhenkov <orangy@jetbrains.com>2014-07-11 19:23:45 +0400
commit484ec26c7d22f4d84b7054b9e243b422acaff3dd (patch)
tree18027117a60c38ba7f8800c8c1abdcde1ae38b19 /src/DocumentationBuilder.kt
parent35b64fb01d6b4da4b0dab840a787abc84d1bff06 (diff)
downloaddokka-484ec26c7d22f4d84b7054b9e243b422acaff3dd.tar.gz
dokka-484ec26c7d22f4d84b7054b9e243b422acaff3dd.tar.bz2
dokka-484ec26c7d22f4d84b7054b9e243b422acaff3dd.zip
Add tests for packages, implement simple comment text extraction, build model for functions and parameters.
Diffstat (limited to 'src/DocumentationBuilder.kt')
-rw-r--r--src/DocumentationBuilder.kt25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/DocumentationBuilder.kt b/src/DocumentationBuilder.kt
index 02db3540..26ed4f80 100644
--- a/src/DocumentationBuilder.kt
+++ b/src/DocumentationBuilder.kt
@@ -10,23 +10,40 @@ fun BindingContext.createDocumentation(file: JetFile): DocumentationModel {
val packageFragment = getPackageFragment(file)
if (packageFragment == null) throw IllegalArgumentException("File $file should have package fragment")
- val visitor = DocumentationBuilderVisitor()
+ val visitor = DocumentationBuilderVisitor(this)
visitDescriptor(packageFragment, model, visitor)
return model
}
-class DocumentationBuilderVisitor() : DeclarationDescriptorVisitorEmptyBodies<DocumentationNode, DocumentationNode>() {
+class DocumentationBuilderVisitor(val context : BindingContext) : DeclarationDescriptorVisitorEmptyBodies<DocumentationNode, DocumentationNode>() {
override fun visitDeclarationDescriptor(descriptor: DeclarationDescriptor?, data: DocumentationNode?): DocumentationNode? {
- val node = DocumentationNode(descriptor!!.getName().asString(), "doc", DocumentationNodeKind.Function)
+ val doc = context.getDocumentation(descriptor!!).extractText()
+ val node = DocumentationNode(descriptor.getName().asString(), doc, DocumentationNodeKind.Unknown)
data?.addReferenceTo(node, DocumentationReferenceKind.Member)
return node
}
override fun visitValueParameterDescriptor(descriptor: ValueParameterDescriptor?, data: DocumentationNode?): DocumentationNode? {
- val node = DocumentationNode(descriptor!!.getName().asString(), "doc", DocumentationNodeKind.Function)
+ val doc = context.getDocumentation(descriptor!!).extractText()
+ val node = DocumentationNode(descriptor.getName().asString(), doc, DocumentationNodeKind.Parameter)
data?.addReferenceTo(node, DocumentationReferenceKind.Detail)
return node
}
+
+
+ override fun visitFunctionDescriptor(descriptor: FunctionDescriptor?, data: DocumentationNode?): DocumentationNode? {
+ val doc = context.getDocumentation(descriptor!!).extractText()
+ val node = DocumentationNode(descriptor.getName().asString(), doc, DocumentationNodeKind.Function)
+ data?.addReferenceTo(node, DocumentationReferenceKind.Member)
+ return node
+ }
+
+
+ override fun visitPackageFragmentDescriptor(descriptor: PackageFragmentDescriptor?, data: DocumentationNode?): DocumentationNode? {
+ val node = DocumentationNode(descriptor!!.fqName.asString(), "", DocumentationNodeKind.Package)
+ data?.addReferenceTo(node, DocumentationReferenceKind.Member)
+ return node
+ }
}