aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/Model/DocumentationNode.kt
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2016-01-04 20:08:39 +0100
committerDmitry Jemerov <yole@jetbrains.com>2016-01-04 20:08:39 +0100
commit2e77e004919664512f88d3ce8d28697c26f9c521 (patch)
treedc278a37e2152bac89fc3e0582eb1e7fd69eeeb3 /core/src/main/kotlin/Model/DocumentationNode.kt
parentfc13de8cedb956107b624ebb0a7e4c3544a504ca (diff)
downloaddokka-2e77e004919664512f88d3ce8d28697c26f9c521.tar.gz
dokka-2e77e004919664512f88d3ce8d28697c26f9c521.tar.bz2
dokka-2e77e004919664512f88d3ce8d28697c26f9c521.zip
cleanup: DocumentationNode.Kind -> NodeKind, DocumentationReference.Kind -> RefKind
Diffstat (limited to 'core/src/main/kotlin/Model/DocumentationNode.kt')
-rw-r--r--core/src/main/kotlin/Model/DocumentationNode.kt166
1 files changed, 83 insertions, 83 deletions
diff --git a/core/src/main/kotlin/Model/DocumentationNode.kt b/core/src/main/kotlin/Model/DocumentationNode.kt
index 35933aee..ba3edc24 100644
--- a/core/src/main/kotlin/Model/DocumentationNode.kt
+++ b/core/src/main/kotlin/Model/DocumentationNode.kt
@@ -2,9 +2,61 @@ package org.jetbrains.dokka
import java.util.*
+enum class NodeKind {
+ Unknown,
+
+ Package,
+ Class,
+ Interface,
+ Enum,
+ AnnotationClass,
+ EnumItem,
+ Object,
+
+ Constructor,
+ Function,
+ Property,
+ Field,
+
+ CompanionObjectProperty,
+ CompanionObjectFunction,
+
+ Parameter,
+ Receiver,
+ TypeParameter,
+ Type,
+ Supertype,
+ UpperBound,
+ LowerBound,
+ Exception,
+
+ Modifier,
+ NullabilityModifier,
+
+ Module,
+
+ ExternalClass,
+ Annotation,
+
+ Value,
+
+ SourceUrl,
+ SourcePosition,
+
+ /**
+ * A note which is rendered once on a page documenting a group of overloaded functions.
+ * Needs to be generated equally on all overloads.
+ */
+ OverloadGroupNote;
+
+ companion object {
+ val classLike = setOf(Class, Interface, Enum, AnnotationClass, Object)
+ }
+}
+
open class DocumentationNode(val name: String,
content: Content,
- val kind: DocumentationNode.Kind) {
+ val kind: NodeKind) {
private val references = LinkedHashSet<DocumentationReference>()
@@ -14,30 +66,30 @@ open class DocumentationNode(val name: String,
val summary: ContentNode get() = content.summary
val owner: DocumentationNode?
- get() = references(DocumentationReference.Kind.Owner).singleOrNull()?.to
+ get() = references(RefKind.Owner).singleOrNull()?.to
val details: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.Detail).map { it.to }
+ get() = references(RefKind.Detail).map { it.to }
val members: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.Member).map { it.to }
+ get() = references(RefKind.Member).map { it.to }
val inheritedMembers: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.InheritedMember).map { it.to }
+ get() = references(RefKind.InheritedMember).map { it.to }
val extensions: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.Extension).map { it.to }
+ get() = references(RefKind.Extension).map { it.to }
val inheritors: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.Inheritor).map { it.to }
+ get() = references(RefKind.Inheritor).map { it.to }
val overrides: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.Override).map { it.to }
+ get() = references(RefKind.Override).map { it.to }
val links: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.Link).map { it.to }
+ get() = references(RefKind.Link).map { it.to }
val hiddenLinks: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.HiddenLink).map { it.to }
+ get() = references(RefKind.HiddenLink).map { it.to }
val annotations: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.Annotation).map { it.to }
+ get() = references(RefKind.Annotation).map { it.to }
val deprecation: DocumentationNode?
- get() = references(DocumentationReference.Kind.Deprecation).singleOrNull()?.to
+ get() = references(RefKind.Deprecation).singleOrNull()?.to
// TODO: Should we allow node mutation? Model merge will copy by ref, so references are transparent, which could nice
- fun addReferenceTo(to: DocumentationNode, kind: DocumentationReference.Kind) {
+ fun addReferenceTo(to: DocumentationNode, kind: RefKind) {
references.add(DocumentationReference(this, to, kind))
}
@@ -52,77 +104,25 @@ open class DocumentationNode(val name: String,
(content as MutableContent).body()
}
- fun details(kind: DocumentationNode.Kind): List<DocumentationNode> = details.filter { it.kind == kind }
- fun members(kind: DocumentationNode.Kind): List<DocumentationNode> = members.filter { it.kind == kind }
- fun inheritedMembers(kind: DocumentationNode.Kind): List<DocumentationNode> = inheritedMembers.filter { it.kind == kind }
- fun links(kind: DocumentationNode.Kind): List<DocumentationNode> = links.filter { it.kind == kind }
+ fun details(kind: NodeKind): List<DocumentationNode> = details.filter { it.kind == kind }
+ fun members(kind: NodeKind): List<DocumentationNode> = members.filter { it.kind == kind }
+ fun inheritedMembers(kind: NodeKind): List<DocumentationNode> = inheritedMembers.filter { it.kind == kind }
+ fun links(kind: NodeKind): List<DocumentationNode> = links.filter { it.kind == kind }
- fun detail(kind: DocumentationNode.Kind): DocumentationNode = details.filter { it.kind == kind }.single()
- fun member(kind: DocumentationNode.Kind): DocumentationNode = members.filter { it.kind == kind }.single()
- fun link(kind: DocumentationNode.Kind): DocumentationNode = links.filter { it.kind == kind }.single()
+ fun detail(kind: NodeKind): DocumentationNode = details.filter { it.kind == kind }.single()
+ fun member(kind: NodeKind): DocumentationNode = members.filter { it.kind == kind }.single()
+ fun link(kind: NodeKind): DocumentationNode = links.filter { it.kind == kind }.single()
- fun references(kind: DocumentationReference.Kind): List<DocumentationReference> = references.filter { it.kind == kind }
+ fun references(kind: RefKind): List<DocumentationReference> = references.filter { it.kind == kind }
fun allReferences(): Set<DocumentationReference> = references
override fun toString(): String {
return "$kind:$name"
}
-
- enum class Kind {
- Unknown,
-
- Package,
- Class,
- Interface,
- Enum,
- AnnotationClass,
- EnumItem,
- Object,
-
- Constructor,
- Function,
- Property,
- Field,
-
- CompanionObjectProperty,
- CompanionObjectFunction,
-
- Parameter,
- Receiver,
- TypeParameter,
- Type,
- Supertype,
- UpperBound,
- LowerBound,
- Exception,
-
- Modifier,
- NullabilityModifier,
-
- Module,
-
- ExternalClass,
- Annotation,
-
- Value,
-
- SourceUrl,
- SourcePosition,
-
- /**
- * A note which is rendered once on a page documenting a group of overloaded functions.
- * Needs to be generated equally on all overloads.
- */
- OverloadGroupNote;
-
- companion object {
- val classLike = setOf(Class, Interface, Enum, AnnotationClass, Object)
- }
- }
}
class DocumentationModule(name: String, content: Content = Content.Empty)
- : DocumentationNode(name, content, DocumentationNode.Kind.Module) {
+ : DocumentationNode(name, content, NodeKind.Module) {
}
val DocumentationNode.path: List<DocumentationNode>
@@ -132,30 +132,30 @@ val DocumentationNode.path: List<DocumentationNode>
}
fun DocumentationNode.findOrCreatePackageNode(packageName: String, packageContent: Map<String, Content>): DocumentationNode {
- val existingNode = members(DocumentationNode.Kind.Package).firstOrNull { it.name == packageName }
+ val existingNode = members(NodeKind.Package).firstOrNull { it.name == packageName }
if (existingNode != null) {
return existingNode
}
val newNode = DocumentationNode(packageName,
packageContent.getOrElse(packageName) { Content.Empty },
- DocumentationNode.Kind.Package)
- append(newNode, DocumentationReference.Kind.Member)
+ NodeKind.Package)
+ append(newNode, RefKind.Member)
return newNode
}
-fun DocumentationNode.append(child: DocumentationNode, kind: DocumentationReference.Kind) {
+fun DocumentationNode.append(child: DocumentationNode, kind: RefKind) {
addReferenceTo(child, kind)
when (kind) {
- DocumentationReference.Kind.Detail -> child.addReferenceTo(this, DocumentationReference.Kind.Owner)
- DocumentationReference.Kind.Member -> child.addReferenceTo(this, DocumentationReference.Kind.Owner)
- DocumentationReference.Kind.Owner -> child.addReferenceTo(this, DocumentationReference.Kind.Member)
+ RefKind.Detail -> child.addReferenceTo(this, RefKind.Owner)
+ RefKind.Member -> child.addReferenceTo(this, RefKind.Owner)
+ RefKind.Owner -> child.addReferenceTo(this, RefKind.Member)
else -> { /* Do not add any links back for other types */ }
}
}
fun DocumentationNode.appendTextNode(text: String,
- kind: DocumentationNode.Kind,
- refKind: DocumentationReference.Kind = DocumentationReference.Kind.Detail) {
+ kind: NodeKind,
+ refKind: RefKind = RefKind.Detail) {
append(DocumentationNode(text, Content.Empty, kind), refKind)
}