diff options
author | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2018-10-29 17:12:47 +0300 |
---|---|---|
committer | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2018-10-29 17:12:47 +0300 |
commit | 7ef0cf32835d6d652e408a2115d58c37749320c5 (patch) | |
tree | 605ae87a4eff6e85092ec29fff87fdda94b117b9 | |
parent | f30807f4e78939fb59f8e46c39b3e538070aacfd (diff) | |
download | dokka-7ef0cf32835d6d652e408a2115d58c37749320c5.tar.gz dokka-7ef0cf32835d6d652e408a2115d58c37749320c5.tar.bz2 dokka-7ef0cf32835d6d652e408a2115d58c37749320c5.zip |
Cleanup support for NodeRenderContent
-rw-r--r-- | core/src/main/kotlin/Formats/StructuredFormatService.kt | 4 | ||||
-rw-r--r-- | core/src/main/kotlin/Java/JavadocParser.kt | 12 | ||||
-rw-r--r-- | core/src/main/kotlin/Model/Content.kt | 4 | ||||
-rw-r--r-- | core/src/test/kotlin/model/JavaTest.kt | 2 |
4 files changed, 13 insertions, 9 deletions
diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt index ebc9cde6..410de281 100644 --- a/core/src/main/kotlin/Formats/StructuredFormatService.kt +++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt @@ -152,6 +152,10 @@ abstract class StructuredOutputBuilder(val to: StringBuilder, } } + is NodeRenderContent -> { + val node = content.node + appendContent(languageService.render(node, content.mode)) + } is ContentNodeLink -> { val node = content.node val linkTo = if (node != null) locationHref(location, node) else "#" diff --git a/core/src/main/kotlin/Java/JavadocParser.kt b/core/src/main/kotlin/Java/JavadocParser.kt index 9f9ea017..1144763b 100644 --- a/core/src/main/kotlin/Java/JavadocParser.kt +++ b/core/src/main/kotlin/Java/JavadocParser.kt @@ -33,12 +33,12 @@ class JavadocParser( private fun ContentSection.appendTypeElement(signature: String, selector: (DocumentationNode) -> DocumentationNode?) { append(LazyContentBlock { - val node = refGraph.lookupOrWarn(signature, logger)?.let(selector) - if (node != null) { - it.append(NodeRenderContent(node, LanguageService.RenderMode.SUMMARY)) - it.symbol(":") - it.text(" ") - } + val node = refGraph.lookupOrWarn(signature, logger)?.let(selector) ?: return@LazyContentBlock emptyList() + listOf(ContentBlock().apply { + append(NodeRenderContent(node, LanguageService.RenderMode.SUMMARY)) + symbol(":") + text(" ") + }) }) } diff --git a/core/src/main/kotlin/Model/Content.kt b/core/src/main/kotlin/Model/Content.kt index 7c776bdb..87a8023a 100644 --- a/core/src/main/kotlin/Model/Content.kt +++ b/core/src/main/kotlin/Model/Content.kt @@ -35,13 +35,13 @@ class NodeRenderContent( get() = 0 //TODO: Clarify? } -class LazyContentBlock(private val fillChildren: (ContentBlock) -> Unit) : ContentBlock() { +class LazyContentBlock(private val fillChildren: () -> List<ContentNode>) : ContentBlock() { private var computed = false override val children: ArrayList<ContentNode> get() { if (!computed) { computed = true - fillChildren(this) + children.addAll(fillChildren()) } return super.children } diff --git a/core/src/test/kotlin/model/JavaTest.kt b/core/src/test/kotlin/model/JavaTest.kt index 66eb84f1..876d18c0 100644 --- a/core/src/test/kotlin/model/JavaTest.kt +++ b/core/src/test/kotlin/model/JavaTest.kt @@ -23,7 +23,7 @@ public class JavaTest { with(content.sections[1]) { assertEquals("Parameters", tag) assertEquals("value", subjectName) - assertEquals("render(Type:String,SUMMARY): is int parameter", toTestString()) + assertEquals("render(Type:Int,SUMMARY): is int parameter", toTestString()) } with(content.sections[2]) { assertEquals("Author", tag) |