aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/pages/PageBuilder.kt
diff options
context:
space:
mode:
authorSzymon Świstun <sswistun@virtuslab.com>2020-01-23 11:10:37 +0100
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-02-10 12:16:32 +0100
commit612e8c2f6f1b52f19c6ae51aa3d5655dfb43ba0c (patch)
treeb801dba1dd61c17d0d67b91c5f093151955d0e2b /core/src/main/kotlin/pages/PageBuilder.kt
parentf7c67c2ade8b56c6556ec59d9c0adf8643a8e566 (diff)
downloaddokka-612e8c2f6f1b52f19c6ae51aa3d5655dfb43ba0c.tar.gz
dokka-612e8c2f6f1b52f19c6ae51aa3d5655dfb43ba0c.tar.bz2
dokka-612e8c2f6f1b52f19c6ae51aa3d5655dfb43ba0c.zip
formatting
Diffstat (limited to 'core/src/main/kotlin/pages/PageBuilder.kt')
-rw-r--r--core/src/main/kotlin/pages/PageBuilder.kt64
1 files changed, 56 insertions, 8 deletions
diff --git a/core/src/main/kotlin/pages/PageBuilder.kt b/core/src/main/kotlin/pages/PageBuilder.kt
index e8930fae..003cc815 100644
--- a/core/src/main/kotlin/pages/PageBuilder.kt
+++ b/core/src/main/kotlin/pages/PageBuilder.kt
@@ -1,8 +1,9 @@
package org.jetbrains.dokka.pages
-import org.jetbrains.dokka.model.doc.TagWrapper
import org.jetbrains.dokka.model.*
+import org.jetbrains.dokka.model.Enum
import org.jetbrains.dokka.model.Function
+import org.jetbrains.dokka.model.doc.TagWrapper
class DefaultPageBuilder(
override val rootContentGroup: RootContentBuilder
@@ -13,14 +14,21 @@ class DefaultPageBuilder(
override fun pageForPackage(p: Package) =
PackagePageNode(p.name, contentForPackage(p), setOf(p.dri), p,
- p.classes.map { pageForClass(it) } +
+ p.classlikes.map { pageForClasslike(it) } +
p.functions.map { pageForMember(it) })
- override fun pageForClass(c: Class): ClassPageNode =
- ClassPageNode(c.name, contentForClass(c), setOf(c.dri), c,
- c.constructors.map { pageForMember(it) } +
- c.classes.map { pageForClass(it) } +
+ override fun pageForClasslike(c: Classlike): ClasslikePageNode {
+ val constructors = when (c) {
+ is Class -> c.constructors
+ is Enum -> c.constructors
+ else -> emptyList()
+ }
+
+ return ClasslikePageNode(c.name, contentForClasslike(c), setOf(c.dri), c,
+ constructors.map { pageForMember(it) } +
+ c.classlikes.map { pageForClasslike(it) } +
c.functions.map { pageForMember(it) })
+ }
override fun pageForMember(m: CallableNode): MemberPageNode =
when (m) {
@@ -43,7 +51,7 @@ class DefaultPageBuilder(
private fun contentForPackage(p: Package) = group(p) {
header(1) { text("Package ${p.name}") }
- block("Types", 2, ContentKind.Properties, p.classes, p.platformData) {
+ block("Types", 2, ContentKind.Properties, p.classlikes, p.platformData) {
link(it.name, it.dri)
text(it.briefDocTagString)
}
@@ -54,6 +62,12 @@ class DefaultPageBuilder(
}
}
+ private fun contentForClasslike(c: Classlike): ContentGroup = when (c) {
+ is Class -> contentForClass(c)
+ is Enum -> contentForEnum(c)
+ else -> throw IllegalStateException("$c should not be present here")
+ }
+
private fun contentForClass(c: Class) = group(c) {
header(1) { text(c.name) }
c.inherited.takeIf { it.isNotEmpty() }?.let {
@@ -69,7 +83,32 @@ class DefaultPageBuilder(
comment(it.root)
text("\n")
}
+
+ block("Functions", 2, ContentKind.Functions, c.functions, c.platformData) {
+ link(it.name, it.dri)
+ signature(it)
+ text(it.briefDocTagString)
+ }
+ block("Properties", 2, ContentKind.Properties, c.properties, c.platformData) {
+ link(it.name, it.dri)
+ text(it.briefDocTagString)
+ }
+ }
+ }
+
+ fun contentForEnum(c: Enum): ContentGroup = group(c) {
+ header(1) { text("enum ${c.name}") }
+
+ block("Entries", 2, ContentKind.Properties, c.entries, c.platformData) { entry ->
+ link(entry.name, entry.dri)
+ contentForComments(entry)
+ }
+
+ c.inherited.takeIf { it.isNotEmpty() }?.let {
+ header(2) { text("SuperInterfaces") }
+ linkTable(it)
}
+ contentForComments(c)
block("Constructors", 2, ContentKind.Functions, c.constructors, c.platformData) {
link(it.name, it.dri)
signature(it)
@@ -86,6 +125,15 @@ class DefaultPageBuilder(
}
}
+ private fun PageContentBuilder.contentForComments(d: Documentable) =
+ d.commentsData.forEach {
+ it.children.forEach {
+ header(3) { text(it.toHeaderString()) }
+ comment(it.root)
+ text("\n")
+ }
+ }
+
private fun contentForFunction(f: Function) = group(f) {
header(1) { text(f.name) }
signature(f)
@@ -115,5 +163,5 @@ interface PageBuilder {
fun pageForModule(m: Module): ModulePageNode
fun pageForPackage(p: Package): PackagePageNode
fun pageForMember(m: CallableNode): MemberPageNode
- fun pageForClass(c: Class): ClassPageNode
+ fun pageForClasslike(c: Classlike): ClasslikePageNode
} \ No newline at end of file