diff options
Diffstat (limited to 'src/Model')
-rw-r--r-- | src/Model/Content.kt | 28 | ||||
-rw-r--r-- | src/Model/DocumentationNode.kt | 12 |
2 files changed, 28 insertions, 12 deletions
diff --git a/src/Model/Content.kt b/src/Model/Content.kt index 8e9c068d..66267496 100644 --- a/src/Model/Content.kt +++ b/src/Model/Content.kt @@ -98,9 +98,22 @@ fun ContentBlock.link(to: DocumentationNode, body: ContentBlock.() -> Unit) { append(block) } -public class Content() : ContentBlock() { +public open class Content(): ContentBlock() { + public open val sections: List<ContentSection> get() = emptyList() + public open val summary: ContentNode get() = ContentEmpty + public open val description: ContentNode get() = ContentEmpty + + fun findSectionByTag(tag: String): ContentSection? = + sections.firstOrNull { tag.equalsIgnoreCase(it.tag) } + + class object { + val Empty = Content() + } +} + +public open class MutableContent() : Content() { private val sectionList = arrayListOf<ContentSection>() - public val sections: List<ContentSection> + public override val sections: List<ContentSection> get() = sectionList fun addSection(tag: String?, subjectName: String?): ContentSection { @@ -109,12 +122,9 @@ public class Content() : ContentBlock() { return section } - fun findSectionByTag(tag: String): ContentSection? = - sections.firstOrNull { tag.equalsIgnoreCase(it.tag) } - - public val summary: ContentNode get() = children.firstOrNull() ?: ContentEmpty + public override val summary: ContentNode get() = children.firstOrNull() ?: ContentEmpty - public val description: ContentNode by Delegates.lazy { + public override val description: ContentNode by Delegates.lazy { val descriptionNodes = children.drop(1) if (descriptionNodes.isEmpty()) { ContentEmpty @@ -143,10 +153,6 @@ public class Content() : ContentBlock() { val isEmpty: Boolean get() = sections.none() - - class object { - val Empty = Content() - } } fun javadocSectionDisplayName(sectionName: String?): String? = diff --git a/src/Model/DocumentationNode.kt b/src/Model/DocumentationNode.kt index f0c3ddf5..8fec29c4 100644 --- a/src/Model/DocumentationNode.kt +++ b/src/Model/DocumentationNode.kt @@ -3,11 +3,14 @@ package org.jetbrains.dokka import java.util.LinkedHashSet public open class DocumentationNode(val name: String, - val content: Content, + 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? @@ -38,6 +41,13 @@ public open class DocumentationNode(val name: String, 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 links(kind: DocumentationNode.Kind): List<DocumentationNode> = links.filter { it.kind == kind } |