aboutsummaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorPaweł Marks <pmarks@virtuslab.com>2019-11-05 13:19:01 +0100
committerPaweł Marks <Kordyjan@users.noreply.github.com>2019-11-05 13:56:26 +0100
commit26a7c54ccba7df51d0f8bb33277b8a366bfd28f5 (patch)
treebf53fcb9fa7b0c976f93ffccd3a635e1edca419c /core/src
parent61cfbcb990da1fd8fd44c6285e6927a57159d15b (diff)
downloaddokka-26a7c54ccba7df51d0f8bb33277b8a366bfd28f5.tar.gz
dokka-26a7c54ccba7df51d0f8bb33277b8a366bfd28f5.tar.bz2
dokka-26a7c54ccba7df51d0f8bb33277b8a366bfd28f5.zip
Adds constructors to documentation
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/kotlin/DokkaDescriptorVisitor.kt6
-rw-r--r--core/src/main/kotlin/Model/DocumentationNode.kt1
-rw-r--r--core/src/main/kotlin/transformers/DefaultDocumentationToPageTransformer.kt10
3 files changed, 11 insertions, 6 deletions
diff --git a/core/src/main/kotlin/DokkaDescriptorVisitor.kt b/core/src/main/kotlin/DokkaDescriptorVisitor.kt
index 979acdc5..ac54635b 100644
--- a/core/src/main/kotlin/DokkaDescriptorVisitor.kt
+++ b/core/src/main/kotlin/DokkaDescriptorVisitor.kt
@@ -36,6 +36,7 @@ object DokkaDescriptorVisitor : DeclarationDescriptorVisitorEmptyBodies<Document
return Class(
dri,
descriptor.name.asString(),
+ descriptor.constructors.map { visitConstructorDescriptor(it, dri) },
scope.functions(dri),
scope.properties(dri),
scope.classes(dri),
@@ -67,6 +68,11 @@ object DokkaDescriptorVisitor : DeclarationDescriptorVisitorEmptyBodies<Document
)
}
+ override fun visitConstructorDescriptor(
+ descriptor: ConstructorDescriptor,
+ parent: DRI
+ ) = visitFunctionDescriptor(descriptor, parent)
+
override fun visitReceiverParameterDescriptor(
descriptor: ReceiverParameterDescriptor,
parent: DRI
diff --git a/core/src/main/kotlin/Model/DocumentationNode.kt b/core/src/main/kotlin/Model/DocumentationNode.kt
index 48bad7eb..62228556 100644
--- a/core/src/main/kotlin/Model/DocumentationNode.kt
+++ b/core/src/main/kotlin/Model/DocumentationNode.kt
@@ -26,6 +26,7 @@ class Package(
class Class(
override val dri: DRI,
val name: String,
+ val constructors: List<Function>,
override val functions: List<Function>,
override val properties: List<Property>,
override val classes: List<Class>,
diff --git a/core/src/main/kotlin/transformers/DefaultDocumentationToPageTransformer.kt b/core/src/main/kotlin/transformers/DefaultDocumentationToPageTransformer.kt
index 54fd9a27..cae1d652 100644
--- a/core/src/main/kotlin/transformers/DefaultDocumentationToPageTransformer.kt
+++ b/core/src/main/kotlin/transformers/DefaultDocumentationToPageTransformer.kt
@@ -35,7 +35,7 @@ class DefaultDocumentationToPageTransformer(
private fun pageForClass(c: Class, parent: PageNode): ClassPageNode =
ClassPageNode(c.name, contentForClass(c), parent, c.dri, c).apply {
- // TODO: Pages for constructors
+ appendChildren(c.constructors.map { pageForMember(it, this) })
appendChildren(c.classes.map { pageForClass(it, this) })
appendChildren(c.functions.map { pageForMember(it, this) })
appendChildren(c.properties.map { pageForMember(it, this) })
@@ -72,11 +72,9 @@ class DefaultDocumentationToPageTransformer(
private fun contentForClass(c: Class) = content(platformData) {
header(1) { text(c.name) }
markdown(c.rawDocstring, c)
- text("PING PAWEL TO ADD CONSTRUCTORS TO MODEL!!!")
- block("Constructors", emptyList<Function>() /* TODO: CONSTRUCTORS*/) {
- link(it.name, it.dri)
+ block("Constructors", c.constructors) {
+ link("signature for constructor", it.dri)
text(it.briefDocstring)
- text("message to Pawel from the future: you forgot about extracting constructors, didn't you?")
}
block("Functions", c.functions) {
link(it.name, it.dri)
@@ -91,7 +89,7 @@ class DefaultDocumentationToPageTransformer(
markdown(f.rawDocstring, f)
block("Parameters", f.children) {
group {
- text(it.name ?: "RECEIVER")
+ text(it.name ?: "<receiver>")
markdown(it.rawDocstring, it)
}
}