diff options
author | Ilya Ryzhenkov <orangy@jetbrains.com> | 2014-07-11 20:49:04 +0400 |
---|---|---|
committer | Ilya Ryzhenkov <orangy@jetbrains.com> | 2014-07-11 20:49:04 +0400 |
commit | 044308ba60a0d4462ccb7388f16ad17a31d7450d (patch) | |
tree | c93411f0670e29fe333962789c0df97b1602f7be /src/Documentation/DocumentationModel.kt | |
parent | 8a4dad46b171c55dabc5f9be29e1261e1cc5928e (diff) | |
download | dokka-044308ba60a0d4462ccb7388f16ad17a31d7450d.tar.gz dokka-044308ba60a0d4462ccb7388f16ad17a31d7450d.tar.bz2 dokka-044308ba60a0d4462ccb7388f16ad17a31d7450d.zip |
Complete package migration and move files into folders.
Diffstat (limited to 'src/Documentation/DocumentationModel.kt')
-rw-r--r-- | src/Documentation/DocumentationModel.kt | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/Documentation/DocumentationModel.kt b/src/Documentation/DocumentationModel.kt new file mode 100644 index 00000000..0113eb18 --- /dev/null +++ b/src/Documentation/DocumentationModel.kt @@ -0,0 +1,67 @@ +package org.jetbrains.dokka + +import org.jetbrains.jet.lang.resolve.BindingContext +import org.jetbrains.jet.lang.psi.JetFile + +public enum class DocumentationNodeKind { + Unknown + + Package + Class + Object + Constructor + Function + Property + Parameter + TypeParameter + Exception + + Page + Model +} + +public enum class DocumentationReferenceKind { + Member + Detail + Owner + Link + Override +} + +public open 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 } + + // TODO: Should we allow node mutation? Model merge will copy by ref, so references are transparent, which could nice + public fun addReferenceTo(to: DocumentationNode, kind: DocumentationReferenceKind) { + references.add(DocumentationReference(this, to, kind)) + } + + public fun addAllReferencesFrom(other: DocumentationNode) { + references.addAll(other.references) + } + + public fun references(kind: DocumentationReferenceKind): List<DocumentationReference> = references.filter { it.kind == kind } +} + +public class DocumentationModel : DocumentationNode("model", "", DocumentationNodeKind.Model) { + fun merge(other: DocumentationModel): DocumentationModel { + val model = DocumentationModel() + model.addAllReferencesFrom(other) + model.addAllReferencesFrom(this) + return model + } + + public val nodes: List<DocumentationNode> + get() = members +} + +public data class DocumentationReference(val from: DocumentationNode, val to: DocumentationNode, val kind: DocumentationReferenceKind) |