aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/model/Documentable.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/model/Documentable.kt
parentf7c67c2ade8b56c6556ec59d9c0adf8643a8e566 (diff)
downloaddokka-612e8c2f6f1b52f19c6ae51aa3d5655dfb43ba0c.tar.gz
dokka-612e8c2f6f1b52f19c6ae51aa3d5655dfb43ba0c.tar.bz2
dokka-612e8c2f6f1b52f19c6ae51aa3d5655dfb43ba0c.zip
formatting
Diffstat (limited to 'core/src/main/kotlin/model/Documentable.kt')
-rw-r--r--core/src/main/kotlin/model/Documentable.kt120
1 files changed, 102 insertions, 18 deletions
diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt
index 7add2c3f..86ba24b7 100644
--- a/core/src/main/kotlin/model/Documentable.kt
+++ b/core/src/main/kotlin/model/Documentable.kt
@@ -1,9 +1,10 @@
package org.jetbrains.dokka.model
-import org.jetbrains.dokka.model.doc.*
-import org.jetbrains.dokka.transformers.descriptors.KotlinTypeWrapper
import org.jetbrains.dokka.links.DRI
+import org.jetbrains.dokka.model.doc.DocumentationNode
import org.jetbrains.dokka.pages.PlatformData
+import org.jetbrains.dokka.transformers.descriptors.KotlinClassKindTypes
+import org.jetbrains.dokka.transformers.descriptors.KotlinTypeWrapper
class Module(override val name: String, val packages: List<Package>) : Documentable() {
override val dri: DRI = DRI.topLevel
@@ -15,7 +16,7 @@ class Package(
override val dri: DRI,
override val functions: List<Function>,
override val properties: List<Property>,
- override val classes: List<Class>,
+ override val classlikes: List<Classlike>,
override val extra: MutableSet<Extra> = mutableSetOf()
) : ScopeNode() {
override val name = dri.packageName.orEmpty()
@@ -24,16 +25,79 @@ class Package(
class Class(
override val dri: DRI,
override val name: String,
- val kind: ClassKind,
+ override val kind: ClassKind,
val constructors: List<Function>,
override val functions: List<Function>,
override val properties: List<Property>,
- override val classes: List<Class>,
+ override val classlikes: List<Classlike>,
override val expected: ClassPlatformInfo?,
override val actual: List<ClassPlatformInfo>,
override val extra: MutableSet<Extra> = mutableSetOf()
-) : ScopeNode() {
- val inherited by lazy { platformInfo.mapNotNull { (it as? ClassPlatformInfo)?.inherited }.flatten() }
+) : Classlike(
+ name = name,
+ dri = dri,
+ kind = kind,
+ functions = functions,
+ properties = properties,
+ classlikes = classlikes,
+ expected = expected,
+ actual = actual,
+ extra = extra
+)
+
+class Enum(
+ override val dri: DRI,
+ override val name: String,
+ val entries: List<EnumEntry>,
+ val constructors: List<Function>,
+ override val functions: List<Function> = emptyList(),
+ override val properties: List<Property> = emptyList(),
+ override val classlikes: List<Classlike> = emptyList(),
+ override val expected: ClassPlatformInfo? = null,
+ override val actual: List<ClassPlatformInfo>,
+ override val extra: MutableSet<Extra> = mutableSetOf()
+) : Classlike(dri = dri, name = name, kind = KotlinClassKindTypes.ENUM_CLASS, actual = actual) {
+ constructor(c: Classlike, entries: List<EnumEntry>, ctors: List<Function>) : this(
+ dri = c.dri,
+ name = c.name,
+ entries = entries,
+ constructors = ctors,
+ functions = c.functions,
+ properties = c.properties,
+ classlikes = c.classlikes,
+ expected = c.expected,
+ actual = c.actual,
+ extra = c.extra
+ )
+
+ override val children: List<Documentable>
+ get() = entries
+}
+
+class EnumEntry(
+ override val dri: DRI,
+ override val name: String,
+ override val expected: ClassPlatformInfo? = null,
+ override val actual: List<ClassPlatformInfo>,
+ override val extra: MutableSet<Extra> = mutableSetOf()
+) : Classlike(
+ dri = dri,
+ name = name,
+ actual = actual,
+ expected = expected,
+ extra = extra,
+ kind = KotlinClassKindTypes.ENUM_ENTRY
+) {
+ constructor(c: Classlike) : this(
+ dri = c.dri,
+ name = c.name,
+ actual = c.actual,
+ expected = c.expected,
+ extra = c.extra
+ )
+
+ override val children: List<Parameter>
+ get() = emptyList()
}
class Function(
@@ -83,7 +147,8 @@ interface PlatformInfo {
class BasePlatformInfo(
override val documentationNode: DocumentationNode,
- override val platformData: List<PlatformData>) : PlatformInfo {
+ override val platformData: List<PlatformData>
+) : PlatformInfo {
override fun equals(other: Any?): Boolean =
other is PlatformInfo && documentationNode == other.documentationNode
@@ -94,7 +159,8 @@ class BasePlatformInfo(
class ClassPlatformInfo(
val info: PlatformInfo,
- val inherited: List<DRI>) : PlatformInfo by info
+ val inherited: List<DRI>
+) : PlatformInfo by info
abstract class Documentable {
open val expected: PlatformInfo? = null
@@ -114,27 +180,45 @@ abstract class Documentable {
override fun hashCode() = dri.hashCode()
+
+ val commentsData: List<DocumentationNode>
+ get() = platformInfo.map { it.documentationNode }
+
val briefDocTagString: String
get() =
platformInfo
- .firstOrNull()
- ?.documentationNode
- ?.children
- ?.firstOrNull()
- ?.root
- ?.docTagSummary()
- ?.shorten(40) ?: ""
+ .firstOrNull()
+ ?.documentationNode
+ ?.children
+ ?.firstOrNull()
+ ?.root
+ ?.docTagSummary()
+ ?.shorten(40) ?: ""
open val extra: MutableSet<Extra> = mutableSetOf()
}
+abstract class Classlike(
+ override val dri: DRI,
+ override val name: String,
+ open val kind: ClassKind,
+ override val functions: List<Function> = emptyList(),
+ override val properties: List<Property> = emptyList(),
+ override val classlikes: List<Classlike> = emptyList(),
+ override val expected: ClassPlatformInfo? = null,
+ override val actual: List<ClassPlatformInfo>,
+ override val extra: MutableSet<Extra> = mutableSetOf()
+) : ScopeNode() {
+ val inherited by lazy { platformInfo.mapNotNull { (it as? ClassPlatformInfo)?.inherited }.flatten() }
+}
+
abstract class ScopeNode : Documentable() {
abstract val functions: List<Function>
abstract val properties: List<Property>
- abstract val classes: List<Class>
+ abstract val classlikes: List<Classlike>
override val children: List<Documentable>
- get() = functions + properties + classes
+ get() = functions + properties + classlikes
}
abstract class CallableNode : Documentable() {