aboutsummaryrefslogtreecommitdiff
path: root/src/Model/DocumentationBuildingVisitor.kt
diff options
context:
space:
mode:
authorIlya Ryzhenkov <orangy@jetbrains.com>2014-09-29 20:54:59 +0400
committerIlya Ryzhenkov <orangy@jetbrains.com>2014-09-29 20:54:59 +0400
commit778e2b3f7ff62971e18a49d81a8825e5dd894c2e (patch)
treef7fb9506800262ecabb9050ffee4a97e39812ccb /src/Model/DocumentationBuildingVisitor.kt
parent2e3dc238275073a5c7a2e5a14c79337d12492dad (diff)
downloaddokka-778e2b3f7ff62971e18a49d81a8825e5dd894c2e.tar.gz
dokka-778e2b3f7ff62971e18a49d81a8825e5dd894c2e.tar.bz2
dokka-778e2b3f7ff62971e18a49d81a8825e5dd894c2e.zip
Extract content model, make doc model independent from descriptors, parse doccomments with custom parser, some tests failing due to hanging new lines.
Diffstat (limited to 'src/Model/DocumentationBuildingVisitor.kt')
-rw-r--r--src/Model/DocumentationBuildingVisitor.kt121
1 files changed, 0 insertions, 121 deletions
diff --git a/src/Model/DocumentationBuildingVisitor.kt b/src/Model/DocumentationBuildingVisitor.kt
deleted file mode 100644
index 6118b0f5..00000000
--- a/src/Model/DocumentationBuildingVisitor.kt
+++ /dev/null
@@ -1,121 +0,0 @@
-package org.jetbrains.dokka
-
-import org.jetbrains.jet.lang.descriptors.*
-import org.jetbrains.jet.lang.resolve.name.*
-import org.jetbrains.jet.lang.resolve.*
-
-public data class DocumentationOptions(val includeNonPublic : Boolean = false)
-class DocumentationBuildingVisitor(val context: BindingContext,
- val options: DocumentationOptions,
- private val worker: DeclarationDescriptorVisitor<DocumentationNode, DocumentationNode>)
-: DeclarationDescriptorVisitor<DocumentationNode, DocumentationNode> {
-
- private fun visitChildren(descriptors: Collection<DeclarationDescriptor>, data: DocumentationNode) {
- for (descriptor in descriptors) {
- visitChild(descriptor, data)
- }
- }
-
- private fun visitChild(descriptor: DeclarationDescriptor?, data: DocumentationNode) {
- if (descriptor != null && descriptor.isUserCode()) {
- if (options.includeNonPublic || descriptor !is MemberDescriptor || descriptor.getVisibility().isPublicAPI()) {
- descriptor.accept(this, data)
- }
- }
- }
-
- private fun createDocumentation(descriptor: DeclarationDescriptor, data: DocumentationNode): DocumentationNode {
- return descriptor.accept(worker, data)
- }
-
- private fun processCallable(descriptor: CallableDescriptor, data: DocumentationNode): DocumentationNode {
- val node = createDocumentation(descriptor, data)
- visitChildren(descriptor.getTypeParameters(), node)
- visitChild(descriptor.getReceiverParameter(), node)
- visitChildren(descriptor.getValueParameters(), node)
- return node
- }
-
- public override fun visitPackageFragmentDescriptor(descriptor: PackageFragmentDescriptor?, data: DocumentationNode?): DocumentationNode? {
- val node = createDocumentation(descriptor!!, data!!)
- visitChildren(descriptor.getMemberScope().getAllDescriptors(), node)
- return node
- }
-
- public override fun visitPackageViewDescriptor(descriptor: PackageViewDescriptor?, data: DocumentationNode?): DocumentationNode? {
- val node = createDocumentation(descriptor!!, data!!)
- visitChildren(descriptor.getMemberScope().getAllDescriptors(), node)
- return node
- }
-
- public override fun visitVariableDescriptor(descriptor: VariableDescriptor?, data: DocumentationNode?): DocumentationNode? {
- val node = processCallable(descriptor!!, data!!)
- return node
- }
-
- public override fun visitPropertyDescriptor(descriptor: PropertyDescriptor?, data: DocumentationNode?): DocumentationNode? {
- val node = processCallable(descriptor!!, data!!)
- visitChild(descriptor.getGetter(), node)
- visitChild(descriptor.getSetter(), node)
- return node
- }
-
- public override fun visitFunctionDescriptor(descriptor: FunctionDescriptor?, data: DocumentationNode?): DocumentationNode? {
- val node = processCallable(descriptor!!, data!!)
- return node
- }
-
- public override fun visitTypeParameterDescriptor(descriptor: TypeParameterDescriptor?, data: DocumentationNode?): DocumentationNode? {
- val node = createDocumentation(descriptor!!, data!!)
- return node
- }
-
- public override fun visitClassDescriptor(descriptor: ClassDescriptor?, data: DocumentationNode?): DocumentationNode? {
- val node = createDocumentation(descriptor!!, data!!)
- if (descriptor.getKind() != ClassKind.OBJECT) {
- // do not go inside object for class object and constructors, they are generated
- visitChildren(descriptor.getTypeConstructor().getParameters(), node)
- visitChildren(descriptor.getConstructors(), node)
- visitChild(descriptor.getClassObjectDescriptor(), node)
- }
- visitChildren(descriptor.getDefaultType().getMemberScope().getAllDescriptors(), node)
- return node
- }
-
- public override fun visitModuleDeclaration(descriptor: ModuleDescriptor, data: DocumentationNode): DocumentationNode {
- val node = createDocumentation(descriptor, data)
- visitChild(descriptor.getPackage(FqName.ROOT), node)
- return node
- }
-
- public override fun visitConstructorDescriptor(descriptor: ConstructorDescriptor?, data: DocumentationNode?): DocumentationNode? {
- val node = visitFunctionDescriptor(descriptor!!, data)
- return node
- }
-
- public override fun visitScriptDescriptor(scriptDescriptor: ScriptDescriptor?, data: DocumentationNode?): DocumentationNode? {
- val classDescriptor = scriptDescriptor!!.getClassDescriptor()
- val node = visitClassDescriptor(classDescriptor, data)
- return node
- }
-
- public override fun visitValueParameterDescriptor(descriptor: ValueParameterDescriptor?, data: DocumentationNode?): DocumentationNode? {
- val node = visitVariableDescriptor(descriptor!!, data)
- return node
- }
-
- public override fun visitPropertyGetterDescriptor(descriptor: PropertyGetterDescriptor?, data: DocumentationNode?): DocumentationNode? {
- val node = visitFunctionDescriptor(descriptor!!, data)
- return node
- }
-
- public override fun visitPropertySetterDescriptor(descriptor: PropertySetterDescriptor?, data: DocumentationNode?): DocumentationNode? {
- val node = visitFunctionDescriptor(descriptor!!, data)
- return node
- }
-
- public override fun visitReceiverParameterDescriptor(descriptor: ReceiverParameterDescriptor?, data: DocumentationNode?): DocumentationNode? {
- val node = createDocumentation(descriptor!!, data!!)
- return node
- }
-}