aboutsummaryrefslogtreecommitdiff
path: root/src/Model/Content.kt
diff options
context:
space:
mode:
authorIlya Ryzhenkov <orangy@jetbrains.com>2014-10-03 19:09:31 +0400
committerIlya Ryzhenkov <orangy@jetbrains.com>2014-10-03 19:09:31 +0400
commit7c6da4babd01da31c57c5c6c827eb2957c989b1c (patch)
tree1cc063c24326044b9ee968b2278e0864e8ee7051 /src/Model/Content.kt
parenta52e1d543d22fdacf87ec00988b753d2d1107c1d (diff)
downloaddokka-7c6da4babd01da31c57c5c6c827eb2957c989b1c.tar.gz
dokka-7c6da4babd01da31c57c5c6c827eb2957c989b1c.tar.bz2
dokka-7c6da4babd01da31c57c5c6c827eb2957c989b1c.zip
Language Service now formats to ContentNode instead of String.
Diffstat (limited to 'src/Model/Content.kt')
-rw-r--r--src/Model/Content.kt25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/Model/Content.kt b/src/Model/Content.kt
index eb092cb2..1b00bd34 100644
--- a/src/Model/Content.kt
+++ b/src/Model/Content.kt
@@ -9,18 +9,37 @@ public abstract class ContentNode {
val empty = ContentEmpty
}
+ fun append(node : ContentNode) : ContentNode {
+ children.add(node)
+ return this
+ }
+
fun isEmpty() = children.isEmpty()
}
-public object ContentEmpty : ContentNode( )
+public object ContentEmpty : ContentNode()
-public class ContentText(val text : String) : ContentNode( )
-public class ContentBlock() : ContentNode( )
+public class ContentText(val text: String) : ContentNode()
+public class ContentKeyword(val text: String) : ContentNode()
+public class ContentIdentifier(val text: String) : ContentNode()
+public class ContentSymbol(val text: String) : ContentNode()
+public class ContentBlock() : ContentNode()
public class ContentEmphasis() : ContentNode()
public class ContentStrong() : ContentNode()
public class ContentList() : ContentNode()
public class ContentSection(public val label: String) : ContentNode()
+fun content(body: ContentNode.() -> Unit): ContentNode {
+ val block = ContentBlock()
+ block.body()
+ return block
+}
+
+fun ContentNode.text(value: String) = append(ContentText(value))
+fun ContentNode.keyword(value: String) = append(ContentKeyword(value))
+fun ContentNode.symbol(value: String) = append(ContentSymbol(value))
+fun ContentNode.identifier(value: String) = append(ContentIdentifier(value))
+
public class Content() : ContentNode() {
public val sections: Map<String, ContentSection> by Delegates.lazy {
val map = hashMapOf<String, ContentSection>()