aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/renderers/DefaultRenderer.kt2
-rw-r--r--core/src/main/kotlin/transformers/DefaultDocumentationToPageTransformer.kt14
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) {