diff options
author | Paweł Marks <pmarks@virtuslab.com> | 2019-11-05 17:20:21 +0100 |
---|---|---|
committer | Paweł Marks <pmarks@virtuslab.com> | 2019-11-05 17:28:56 +0100 |
commit | 940cf84196f0cd0dbeafae2f0ec5f73a49b68285 (patch) | |
tree | 2515a99b221641cb67c9a32ab109f13c7c3f1e73 | |
parent | ab7333e7ffe6fbfda4e55fcc168dc00eece3f7f8 (diff) | |
download | dokka-940cf84196f0cd0dbeafae2f0ec5f73a49b68285.tar.gz dokka-940cf84196f0cd0dbeafae2f0ec5f73a49b68285.tar.bz2 dokka-940cf84196f0cd0dbeafae2f0ec5f73a49b68285.zip |
Signateures wrapped in symbols
-rw-r--r-- | core/src/main/kotlin/renderers/DefaultRenderer.kt | 2 | ||||
-rw-r--r-- | core/src/main/kotlin/transformers/DefaultDocumentationToPageTransformer.kt | 14 |
2 files changed, 13 insertions, 3 deletions
diff --git a/core/src/main/kotlin/renderers/DefaultRenderer.kt b/core/src/main/kotlin/renderers/DefaultRenderer.kt index a2ca4131..e3b3fbeb 100644 --- a/core/src/main/kotlin/renderers/DefaultRenderer.kt +++ b/core/src/main/kotlin/renderers/DefaultRenderer.kt @@ -14,7 +14,7 @@ abstract class DefaultRenderer(val fileWriter: FileWriter, val locationProvider: protected open fun buildHeader(level: Int, content: List<ContentNode>, pageContext: PageNode): String = buildHeader(level, content.joinToString { it.build(pageContext) }) protected open fun buildGroup(children: List<ContentNode>, pageContext: PageNode): String = children.joinToString { it.build(pageContext) } protected open fun buildComment(parts: List<ContentNode>, pageContext: PageNode): String = parts.joinToString { it.build(pageContext) } - protected open fun buildSymbol(parts: List<ContentNode>, pageContext: PageNode): String = parts.joinToString { it.build(pageContext) } + protected open fun buildSymbol(parts: List<ContentNode>, pageContext: PageNode): String = parts.joinToString(separator = "") { it.build(pageContext) } protected open fun buildBlock(name: String, content: List<ContentNode>, pageContext: PageNode) = buildHeader(3, name) + content.joinToString("\n") { it.build(pageContext) } protected open fun ContentNode.build(pageContext: PageNode): String = buildContentNode(this, pageContext) diff --git a/core/src/main/kotlin/transformers/DefaultDocumentationToPageTransformer.kt b/core/src/main/kotlin/transformers/DefaultDocumentationToPageTransformer.kt index 0427b9b6..a3966d62 100644 --- a/core/src/main/kotlin/transformers/DefaultDocumentationToPageTransformer.kt +++ b/core/src/main/kotlin/transformers/DefaultDocumentationToPageTransformer.kt @@ -111,6 +111,10 @@ class DefaultDocumentationToPageTransformer( contents += ContentText(text, platformData) } + inline fun symbol(block: ContentBuilder.() -> Unit) { + contents += ContentSymbol(content(block), platformData) + } + inline fun <T> block(name: String, elements: Iterable<T>, block: ContentBuilder.(T) -> Unit) { contents += ContentBlock(name, content { elements.forEach { block(it) } }, platformData) } @@ -152,10 +156,10 @@ class DefaultDocumentationToPageTransformer( ContentBuilder(platformData).apply(block).build() // When builder is made public it will be moved as extension method to someplace near Function model - private fun ContentBuilder.signature(f: Function) { + private fun ContentBuilder.signature(f: Function) = symbol { text("fun ") if (f.receiver is Parameter) { - type(f.receiver.descriptor.type) + type(f.receiver.descriptor.type) text(".") } link(f.name, f.dri) @@ -166,6 +170,12 @@ class DefaultDocumentationToPageTransformer( type(it.descriptor.type) } text(")") + val returnType = f.descriptor.returnType + if (returnType != null && + returnType.constructor.declarationDescriptor?.fqNameSafe?.asString() != Unit::class.qualifiedName) { + text(": ") + type(returnType) + } } private fun ContentBuilder.type(t: KotlinType) { |