aboutsummaryrefslogtreecommitdiff
path: root/src/Model/DocumentationNode.kt
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2015-12-03 16:22:11 +0100
committerDmitry Jemerov <yole@jetbrains.com>2015-12-03 16:22:49 +0100
commit39631054c58df5841ea268b7002b820ec55f6e0a (patch)
treecefedd8411c859243bd181568e16fcdd372a38c8 /src/Model/DocumentationNode.kt
parent797cb4732c53bf1e3b2091add8cf731fc436607f (diff)
downloaddokka-39631054c58df5841ea268b7002b820ec55f6e0a.tar.gz
dokka-39631054c58df5841ea268b7002b820ec55f6e0a.tar.bz2
dokka-39631054c58df5841ea268b7002b820ec55f6e0a.zip
restructure Dokka build to use Gradle for everything except for the Maven plugin
Diffstat (limited to 'src/Model/DocumentationNode.kt')
-rw-r--r--src/Model/DocumentationNode.kt162
1 files changed, 0 insertions, 162 deletions
diff --git a/src/Model/DocumentationNode.kt b/src/Model/DocumentationNode.kt
deleted file mode 100644
index 52881f65..00000000
--- a/src/Model/DocumentationNode.kt
+++ /dev/null
@@ -1,162 +0,0 @@
-package org.jetbrains.dokka
-
-import java.util.*
-
-public open class DocumentationNode(val name: String,
- content: Content,
- val kind: DocumentationNode.Kind) {
-
- private val references = LinkedHashSet<DocumentationReference>()
-
- var content: Content = content
- private set
-
- public val summary: ContentNode get() = content.summary
-
- public val owner: DocumentationNode?
- get() = references(DocumentationReference.Kind.Owner).singleOrNull()?.to
- public val details: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.Detail).map { it.to }
- public val members: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.Member).map { it.to }
- public val inheritedMembers: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.InheritedMember).map { it.to }
- public val extensions: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.Extension).map { it.to }
- public val inheritors: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.Inheritor).map { it.to }
- public val overrides: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.Override).map { it.to }
- public val links: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.Link).map { it.to }
- public val hiddenLinks: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.HiddenLink).map { it.to }
- public val annotations: List<DocumentationNode>
- get() = references(DocumentationReference.Kind.Annotation).map { it.to }
- public val deprecation: DocumentationNode?
- get() = references(DocumentationReference.Kind.Deprecation).singleOrNull()?.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: DocumentationReference.Kind) {
- references.add(DocumentationReference(this, to, kind))
- }
-
- public fun addAllReferencesFrom(other: DocumentationNode) {
- references.addAll(other.references)
- }
-
- public fun updateContent(body: MutableContent.() -> Unit) {
- if (content !is MutableContent) {
- content = MutableContent()
- }
- (content as MutableContent).body()
- }
-
- public fun details(kind: DocumentationNode.Kind): List<DocumentationNode> = details.filter { it.kind == kind }
- public fun members(kind: DocumentationNode.Kind): List<DocumentationNode> = members.filter { it.kind == kind }
- public fun inheritedMembers(kind: DocumentationNode.Kind): List<DocumentationNode> = inheritedMembers.filter { it.kind == kind }
- public fun links(kind: DocumentationNode.Kind): List<DocumentationNode> = links.filter { it.kind == kind }
-
- public fun detail(kind: DocumentationNode.Kind): DocumentationNode = details.filter { it.kind == kind }.single()
- public fun member(kind: DocumentationNode.Kind): DocumentationNode = members.filter { it.kind == kind }.single()
- public fun link(kind: DocumentationNode.Kind): DocumentationNode = links.filter { it.kind == kind }.single()
-
- public fun references(kind: DocumentationReference.Kind): List<DocumentationReference> = references.filter { it.kind == kind }
- public fun allReferences(): Set<DocumentationReference> = references
-
- public override fun toString(): String {
- return "$kind:$name"
- }
-
- public 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)
- }
- }
-}
-
-public class DocumentationModule(name: String, content: Content = Content.Empty)
- : DocumentationNode(name, content, DocumentationNode.Kind.Module) {
-}
-
-val DocumentationNode.path: List<DocumentationNode>
- get() {
- val parent = owner ?: return listOf(this)
- return parent.path + this
- }
-
-fun DocumentationNode.findOrCreatePackageNode(packageName: String, packageContent: Map<String, Content>): DocumentationNode {
- val existingNode = members(DocumentationNode.Kind.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)
- return newNode
-}
-
-fun DocumentationNode.append(child: DocumentationNode, kind: DocumentationReference.Kind) {
- 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)
- else -> { /* Do not add any links back for other types */ }
- }
-}
-
-fun DocumentationNode.appendTextNode(text: String,
- kind: DocumentationNode.Kind,
- refKind: DocumentationReference.Kind = DocumentationReference.Kind.Detail) {
- append(DocumentationNode(text, Content.Empty, kind), refKind)
-}
-
-fun DocumentationNode.qualifiedName() = path.drop(1).map { it.name }.filter { it.length > 0 }.joinToString(".")