aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIlya Ryzhenkov <orangy@jetbrains.com>2014-07-11 17:44:02 +0400
committerIlya Ryzhenkov <orangy@jetbrains.com>2014-07-11 17:44:02 +0400
commitc540bc28a79092b212e575fa18d33399faee83b9 (patch)
tree48b7bdd02b3d948b2dae3950aa44cf57ef46d4f6 /src
parentdeae3bfbe0a5bda997f3033693879042a058de3a (diff)
downloaddokka-c540bc28a79092b212e575fa18d33399faee83b9.tar.gz
dokka-c540bc28a79092b212e575fa18d33399faee83b9.tar.bz2
dokka-c540bc28a79092b212e575fa18d33399faee83b9.zip
Building model from nodes with references.
Diffstat (limited to 'src')
-rw-r--r--src/DocumentationModel.kt65
1 files changed, 59 insertions, 6 deletions
diff --git a/src/DocumentationModel.kt b/src/DocumentationModel.kt
index 77b38d79..3391c277 100644
--- a/src/DocumentationModel.kt
+++ b/src/DocumentationModel.kt
@@ -3,19 +3,72 @@ package com.jetbrains.dokka
import com.intellij.psi.PsiFile
import org.jetbrains.jet.lang.resolve.BindingContext
-public class DocumentationNode {
- val name = "fn"
- val doc = "doc"
+public enum class DocumentationNodeKind {
+ Package
+ Class
+ Function
+ Property
+ Parameter
+ TypeParameter
+ Exception
+
+ Page
+ Module
+}
+
+public enum class DocumentationReferenceKind {
+ Member
+ Detail
+ Owner
+ Link
+ Override
+}
+
+public class DocumentationNode(val name: String, val doc: String, val kind: DocumentationNodeKind) {
+ private val references = arrayListOf<DocumentationReference>()
+
+ public val owner: DocumentationNode
+ get() = references(DocumentationReferenceKind.Owner).single().to
+ public val details: List<DocumentationNode>
+ get() = references(DocumentationReferenceKind.Detail).map { it.to }
+ public val members: List<DocumentationNode>
+ get() = references(DocumentationReferenceKind.Member).map { it.to }
+ public val links: List<DocumentationNode>
+ get() = references(DocumentationReferenceKind.Link).map { it.to }
+
+ public fun addReferenceTo(to: DocumentationNode, kind: DocumentationReferenceKind) {
+ references.add(DocumentationReference(this, to, kind))
+ }
+
+ public fun references(kind: DocumentationReferenceKind): List<DocumentationReference> = references.filter { it.kind == kind }
}
public class DocumentationModel {
+ private val items = arrayListOf<DocumentationNode>()
+
fun merge(other: DocumentationModel): DocumentationModel {
- return DocumentationModel()
+ val model = DocumentationModel()
+ model.addNodes(other.nodes)
+ model.addNodes(this.nodes)
+ return model
+ }
+
+ public fun addNode(node: DocumentationNode) {
+ items.add(node)
}
- val items : List<DocumentationNode> = listOf(DocumentationNode())
+ public fun addNodes(nodes: List<DocumentationNode>) {
+ items.addAll(nodes)
+ }
+
+ public val nodes: List<DocumentationNode>
+ get() = items
}
+public data class DocumentationReference(val from: DocumentationNode, val to: DocumentationNode, val kind: DocumentationReferenceKind)
+
fun BindingContext.createDocumentation(file: PsiFile): DocumentationModel {
- return DocumentationModel()
+ val model = DocumentationModel()
+ model.addNode(DocumentationNode("fn", "doc", DocumentationNodeKind.Function))
+ return model
} \ No newline at end of file