diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-10-27 18:37:35 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-10-29 11:57:20 +0100 |
commit | 8291bee3a86f5f2409ba4ae44c87f291c664ac19 (patch) | |
tree | a0a4558c4c48184ed630dc62d34f8898f7546b44 /src/Model | |
parent | 3faa3f2d1c7ca33ad8d98bc6c562e4fe6977225f (diff) | |
download | dokka-8291bee3a86f5f2409ba4ae44c87f291c664ac19.tar.gz dokka-8291bee3a86f5f2409ba4ae44c87f291c664ac19.tar.bz2 dokka-8291bee3a86f5f2409ba4ae44c87f291c664ac19.zip |
wrapping and nicer formatting for signatures
Diffstat (limited to 'src/Model')
-rw-r--r-- | src/Model/Content.kt | 59 |
1 files changed, 51 insertions, 8 deletions
diff --git a/src/Model/Content.kt b/src/Model/Content.kt index 4dfd3606..e7dfc241 100644 --- a/src/Model/Content.kt +++ b/src/Model/Content.kt @@ -1,8 +1,12 @@ package org.jetbrains.dokka -public interface ContentNode +public interface ContentNode { + val textLength: Int +} -public object ContentEmpty : ContentNode +public object ContentEmpty : ContentNode { + override val textLength: Int get() = 0 +} public open class ContentBlock() : ContentNode { val children = arrayListOf<ContentNode>() @@ -18,6 +22,9 @@ public open class ContentBlock() : ContentNode { override fun hashCode(): Int = children.hashCode() + + override val textLength: Int + get() = children.sumBy { it.textLength } } enum class IdentifierKind { @@ -28,12 +35,45 @@ enum class IdentifierKind { Other } -public data class ContentText(val text: String) : ContentNode -public data class ContentKeyword(val text: String) : ContentNode -public data class ContentIdentifier(val text: String, val kind: IdentifierKind = IdentifierKind.Other) : ContentNode -public data class ContentSymbol(val text: String) : ContentNode -public data class ContentEntity(val text: String) : ContentNode -public object ContentNonBreakingSpace: ContentNode +public data class ContentText(val text: String) : ContentNode { + override val textLength: Int + get() = text.length +} + +public data class ContentKeyword(val text: String) : ContentNode { + override val textLength: Int + get() = text.length +} + +public data class ContentIdentifier(val text: String, val kind: IdentifierKind = IdentifierKind.Other) : ContentNode { + override val textLength: Int + get() = text.length +} + +public data class ContentSymbol(val text: String) : ContentNode { + override val textLength: Int + get() = text.length +} + +public data class ContentEntity(val text: String) : ContentNode { + override val textLength: Int + get() = text.length +} + +public object ContentNonBreakingSpace: ContentNode { + override val textLength: Int + get() = 1 +} + +public object ContentSoftLineBreak: ContentNode { + override val textLength: Int + get() = 0 +} + +public object ContentIndentedSoftLineBreak: ContentNode { + override val textLength: Int + get() = 0 +} public class ContentParagraph() : ContentBlock() public class ContentEmphasis() : ContentBlock() @@ -97,6 +137,9 @@ fun ContentBlock.keyword(value: String) = append(ContentKeyword(value)) fun ContentBlock.symbol(value: String) = append(ContentSymbol(value)) fun ContentBlock.identifier(value: String, kind: IdentifierKind = IdentifierKind.Other) = append(ContentIdentifier(value, kind)) fun ContentBlock.nbsp() = append(ContentNonBreakingSpace) +fun ContentBlock.softLineBreak() = append(ContentSoftLineBreak) +fun ContentBlock.indentedSoftLineBreak() = append(ContentIndentedSoftLineBreak) + fun ContentBlock.strong(body: ContentBlock.() -> Unit) { val strong = ContentStrong() strong.body() |