diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-01-30 19:01:40 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-01-30 19:01:40 +0100 |
commit | 0fac1d925b74f24002a4e1538088ce66c4b02cb9 (patch) | |
tree | 5cf3800e961b9da84b2db03707603865496f5ed0 /src/Model | |
parent | bfd9ffd13ed6b6916790f5f0de5f9523db71b22e (diff) | |
download | dokka-0fac1d925b74f24002a4e1538088ce66c4b02cb9.tar.gz dokka-0fac1d925b74f24002a4e1538088ce66c4b02cb9.tar.bz2 dokka-0fac1d925b74f24002a4e1538088ce66c4b02cb9.zip |
code review
Diffstat (limited to 'src/Model')
-rw-r--r-- | src/Model/Content.kt | 24 | ||||
-rw-r--r-- | src/Model/DocumentationNode.kt | 8 |
2 files changed, 13 insertions, 19 deletions
diff --git a/src/Model/Content.kt b/src/Model/Content.kt index 2fae317d..e59037d2 100644 --- a/src/Model/Content.kt +++ b/src/Model/Content.kt @@ -1,5 +1,7 @@ package org.jetbrains.dokka +import kotlin.properties.Delegates + public abstract class ContentNode { val children = arrayListOf<ContentNode>() @@ -32,7 +34,7 @@ public class ContentNodeLink(val node : DocumentationNode) : ContentBlock() public class ContentExternalLink(val href : String) : ContentBlock() public class ContentList() : ContentBlock() public class ContentListItem() : ContentBlock() -public class ContentSection(public val label: String, public val subjectName: String?) : ContentBlock() +public class ContentSection(public val tag: String, public val subjectName: String?) : ContentBlock() fun content(body: ContentNode.() -> Unit): ContentNode { val block = ContentBlock() @@ -62,22 +64,20 @@ public class Content() : ContentNode() { return section } - fun findSectionByName(name: String): ContentSection? = - sections.firstOrNull { it.label == name } - - fun getSectionsWithSubjects(): Map<String, List<ContentSection>> = - sections.filter { it.subjectName != null }.groupBy { it.label } + fun findSectionByTag(tag: String): ContentSection? = + sections.firstOrNull { tag.equalsIgnoreCase(it.tag) } public val summary: ContentNode get() = children.firstOrNull() ?: ContentEmpty - public val description: ContentNode get() { + public val description: ContentNode by Delegates.lazy { val descriptionNodes = children.drop(1) if (descriptionNodes.isEmpty()) { - return ContentEmpty + ContentEmpty + } else { + val result = ContentSection("Description", null) + result.children.addAll(descriptionNodes) + result } - val result = ContentSection("\$description", null) - result.children.addAll(descriptionNodes) - return result } override fun equals(other: Any?): Boolean { @@ -93,7 +93,7 @@ public class Content() : ContentNode() { override fun toString(): String { if (sections.isEmpty()) return "<empty>" - return sections.joinToString() + return (listOf(summary, description) + sections).joinToString() } val isEmpty: Boolean diff --git a/src/Model/DocumentationNode.kt b/src/Model/DocumentationNode.kt index 3a61b8fb..c3700069 100644 --- a/src/Model/DocumentationNode.kt +++ b/src/Model/DocumentationNode.kt @@ -8,13 +8,7 @@ public open class DocumentationNode(val name: String, private val references = LinkedHashSet<DocumentationReference>() - - public val summary: ContentNode get() { - val contentSection = content.summary - if (contentSection != null) - return contentSection - return ContentNode.empty - } + public val summary: ContentNode get() = content.summary public val owner: DocumentationNode? get() = references(DocumentationReference.Kind.Owner).singleOrNull()?.to |