diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-02-20 17:01:26 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-02-20 17:01:26 +0100 |
commit | bfe53b9ea3359baee1785c2f6291bb5408597e28 (patch) | |
tree | 07678730112e424224b7be8ca2758cb382fc2028 /src/Model | |
parent | 69c3638e173d1b08e02af0d7723c27cb025cea7d (diff) | |
download | dokka-bfe53b9ea3359baee1785c2f6291bb5408597e28.tar.gz dokka-bfe53b9ea3359baee1785c2f6291bb5408597e28.tar.bz2 dokka-bfe53b9ea3359baee1785c2f6291bb5408597e28.zip |
resolve content links to declaration descriptors immediately during markdown to content tree conversion; remove separate phase for resolving links in content
Diffstat (limited to 'src/Model')
-rw-r--r-- | src/Model/Content.kt | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/Model/Content.kt b/src/Model/Content.kt index 9864ee42..01d7b206 100644 --- a/src/Model/Content.kt +++ b/src/Model/Content.kt @@ -38,12 +38,26 @@ public class ContentStrikethrough() : ContentBlock() public class ContentCode() : ContentBlock() public class ContentBlockCode() : ContentBlock() -public class ContentNodeLink(val node : DocumentationNode) : ContentBlock() { +public abstract class ContentNodeLink() : ContentBlock() { + abstract val node: DocumentationNode +} + +public class ContentNodeDirectLink(override val node: DocumentationNode): ContentNodeLink() { + override fun equals(other: Any?): Boolean = + super.equals(other) && other is ContentNodeDirectLink && node.name == other.node.name + + override fun hashCode(): Int = + children.hashCode() * 31 + node.name.hashCode() +} + +public class ContentNodeLazyLink(val linkText: String, val lazyNode: () -> DocumentationNode): ContentNodeLink() { + override val node: DocumentationNode get() = lazyNode() + override fun equals(other: Any?): Boolean = - super.equals(other) && other is ContentNodeLink && node.name == other.node.name + super.equals(other) && other is ContentNodeLazyLink && linkText == other.linkText override fun hashCode(): Int = - children.hashCode() * 31 + node.name.hashCode() + children.hashCode() * 31 + linkText.hashCode() } public class ContentExternalLink(val href : String) : ContentBlock() { @@ -77,7 +91,7 @@ fun ContentBlock.symbol(value: String) = append(ContentSymbol(value)) fun ContentBlock.identifier(value: String) = append(ContentIdentifier(value)) fun ContentBlock.link(to: DocumentationNode, body: ContentBlock.() -> Unit) { - val block = ContentNodeLink(to) + val block = ContentNodeDirectLink(to) block.body() append(block) } |