diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-02-13 12:38:32 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-02-13 12:38:32 +0100 |
commit | 4a018fa175bee9e7223232cbaf6365c81c540239 (patch) | |
tree | e277a18871531336c026e2d83adc163d398d3f42 /src/Model/DocumentationNode.kt | |
parent | ba58510ffba0be044fa13214e38d3fe24186b804 (diff) | |
download | dokka-4a018fa175bee9e7223232cbaf6365c81c540239.tar.gz dokka-4a018fa175bee9e7223232cbaf6365c81c540239.tar.bz2 dokka-4a018fa175bee9e7223232cbaf6365c81c540239.zip |
allow multiple builders to provide package nodes; move some kotlin-independent logic to DocumentationNode
Diffstat (limited to 'src/Model/DocumentationNode.kt')
-rw-r--r-- | src/Model/DocumentationNode.kt | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/Model/DocumentationNode.kt b/src/Model/DocumentationNode.kt index c3700069..64a854a8 100644 --- a/src/Model/DocumentationNode.kt +++ b/src/Model/DocumentationNode.kt @@ -101,4 +101,23 @@ val DocumentationNode.path: List<DocumentationNode> if (parent == null) return listOf(this) return parent.path + this - }
\ No newline at end of file + } + +fun DocumentationNode.findOrCreatePackageNode(packageName: String): DocumentationNode { + val existingNode = members(DocumentationNode.Kind.Package).firstOrNull { it.name == packageName } + if (existingNode != null) { + return existingNode + } + val newNode = DocumentationNode(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) + } +} |