aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Doległo <kamilok1965@interia.pl>2019-11-07 16:12:11 +0100
committerKamil Doległo <kamilok1965@interia.pl>2019-11-12 18:04:48 +0100
commit86e5f8e35a1a6a834dda723421af048be7b7ca1b (patch)
tree3f67e2f19cacab14017e96663e0a1b8e2e632e5e
parent493951f487910a1306a4129b7e8144e679c0213c (diff)
downloaddokka-86e5f8e35a1a6a834dda723421af048be7b7ca1b.tar.gz
dokka-86e5f8e35a1a6a834dda723421af048be7b7ca1b.tar.bz2
dokka-86e5f8e35a1a6a834dda723421af048be7b7ca1b.zip
New ContentNode structure
-rw-r--r--core/src/main/kotlin/pages/ContentNodes.kt180
-rw-r--r--core/src/main/kotlin/pages/PageNodes.kt5
2 files changed, 106 insertions, 79 deletions
diff --git a/core/src/main/kotlin/pages/ContentNodes.kt b/core/src/main/kotlin/pages/ContentNodes.kt
index a2b884a8..b5dc027f 100644
--- a/core/src/main/kotlin/pages/ContentNodes.kt
+++ b/core/src/main/kotlin/pages/ContentNodes.kt
@@ -2,89 +2,119 @@ package org.jetbrains.dokka.pages
import org.jetbrains.dokka.links.DRI
+data class DCI(val dri: DRI, val kind: Kind) {
+ override fun toString() = "$dri[$kind]"
+}
+
interface ContentNode {
val dci: DCI
- val annotations: List<Annotation>
+ val platforms: Set<PlatformData>
+ val style: Set<Style>
+ val extras: Set<Extra>
}
-/** Comment consisting of parts, eg. [ContentText]s, [ContentLink]s and so on */
-data class ContentComment(val parts: List<ContentNode>,
- override val dci: DCI,
- override val annotations: List<Annotation> = emptyList()
-): ContentNode
-
/** Simple text */
-data class ContentText(val text: String,
- override val dci: DCI,
- override val annotations: List<Annotation> = emptyList()
-): ContentNode
-
-///** Headers */ TODO for next iteration
-data class ContentHeader(val items: List<ContentNode>,
- val level: Int,
- override val dci: DCI,
- override val annotations: List<Annotation> = emptyList()
-): ContentNode
-
-/** Lists */
-data class ContentList(val items: List<ContentNode>,
- val ordered: Boolean,
- override val dci: DCI,
- override val annotations: List<Annotation> = emptyList()
-): ContentNode
-
-/** Styled elements, eg. bold, strikethrough, emphasis and so on **/
-data class ContentStyle(val items: List<ContentNode>,
- val style: IStyle,
- override val dci: DCI,
- override val annotations: List<Annotation> = emptyList()
-): ContentNode
+data class ContentText(
+ val text: String,
+ override val dci: DCI,
+ override val platforms: Set<PlatformData>,
+ override val style: Set<Style> = emptySet(),
+ override val extras: Set<Extra> = emptySet()
+) : ContentNode
+
+/** Headers */
+data class ContentHeader(
+ override val children: List<ContentNode>,
+ val level: Int,
+ override val dci: DCI,
+ override val platforms: Set<PlatformData>,
+ override val style: Set<Style>,
+ override val extras: Set<Extra>
+) : ContentComposite
/** Code blocks */
-data class ContentCode(val code: String,
- val language: String,
- override val dci: DCI,
- override val annotations: List<Annotation> = emptyList()
-): ContentNode
-
-/** Symbols, eg. `open fun foo(): String`, or `class Bar`, consisting of parts like [ContentText] and [ContentLink] */
-data class ContentSymbol(val parts: List<ContentNode>,
- override val dci: DCI,
- override val annotations: List<Annotation> = emptyList()
-): ContentNode
+data class ContentCode(
+ override val children: List<ContentNode>,
+ val language: String,
+ override val dci: DCI,
+ override val platforms: Set<PlatformData>,
+ override val style: Set<Style>,
+ override val extras: Set<Extra>
+) : ContentComposite
+
+/** Union type replacement */
+interface ContentLink : ContentComposite
/** All links to classes, packages, etc. that have te be resolved */
-data class ContentLink(val text: String,
- val address: DRI,
- override val dci: DCI,
- override val annotations: List<Annotation> = emptyList()
-): ContentNode
+data class ContentDRILink(
+ override val children: List<ContentNode>,
+ val address: DRI,
+ override val dci: DCI,
+ override val platforms: Set<PlatformData>,
+ override val style: Set<Style> = emptySet(),
+ override val extras: Set<Extra> = emptySet()
+) : ContentLink
/** All links that do not need to be resolved */
-data class ContentResolvedLink(val text: String,
- val address: String,
- override val dci: DCI,
- override val annotations: List<Annotation> = emptyList()
-): ContentNode
-
-/** Blocks of [ContentNode]s with name, eg. Functions, Types, Properties, etc. */
-data class ContentBlock(val name: String,
- val children: List<ContentNode>,
- override val dci: DCI,
- override val annotations: List<Annotation> = emptyList()
-): ContentNode
-
-/** Logical grouping of [ContentNode]s, eg. [ContentLink], [ContentText] and [ContentSymbol] for one entity */
-data class ContentGroup(val children: List<ContentNode>,
- override val dci: DCI,
- override val annotations: List<Annotation> = emptyList()
-): ContentNode
-
-/** All annotations */
-data class Annotation(val name: String)
-
-interface IStyle
-
-enum class Style: IStyle {
- Emphasis, Strong, Paragraph
-} \ No newline at end of file
+data class ContentResolvedLink(
+ override val children: List<ContentNode>,
+ val address: String,
+ override val dci: DCI,
+ override val platforms: Set<PlatformData>,
+ override val style: Set<Style> = emptySet(),
+ override val extras: Set<Extra> = emptySet()
+) : ContentLink
+
+/** All links that do not need to be resolved */
+data class ContentEmbeddedResource(
+ val address: String,
+ override val dci: DCI,
+ override val platforms: Set<PlatformData>,
+ override val style: Set<Style> = emptySet(),
+ override val extras: Set<Extra> = emptySet()
+) : ContentLink {
+ override val children = emptyList<ContentNode>()
+}
+
+/** Logical grouping of [ContentNode]s */
+interface ContentComposite : ContentNode {
+ val children: List<ContentNode>
+}
+
+/** Lists */
+data class ContentList(
+ override val children: List<ContentNode>,
+ val ordered: Boolean,
+ override val dci: DCI,
+ override val platforms: Set<PlatformData>,
+ override val style: Set<Style>,
+ override val extras: Set<Extra>
+) : ContentComposite
+
+/** Default group, eg. for blocks of Functions, Properties, etc. **/
+data class ContentGroup(
+ override val children: List<ContentNode>,
+ override val dci: DCI,
+ override val platforms: Set<PlatformData>,
+ override val style: Set<Style>,
+ override val extras: Set<Extra>
+) : ContentComposite
+
+/** All extras */
+interface Extra
+interface Style
+interface Kind
+
+enum class ContentKind : Kind {
+ Comment, Functions, Parameters, Properties, Classes, Packages, Symbol, Sample
+}
+
+enum class TextStyle : Style {
+ Bold, Italic, Strong, Strikethrough, TableHeader
+}
+
+enum class RenderStyle : Style {
+ Block, Inline, Table, Paragraph
+}
+
+//data class HTMLMetadata(val key: String, val value: String): Extra \ No newline at end of file
diff --git a/core/src/main/kotlin/pages/PageNodes.kt b/core/src/main/kotlin/pages/PageNodes.kt
index 34662720..41692256 100644
--- a/core/src/main/kotlin/pages/PageNodes.kt
+++ b/core/src/main/kotlin/pages/PageNodes.kt
@@ -61,11 +61,8 @@ data class PlatformData(val platformName: String, val platformType: Platform) {
override fun toString() = platformName
}
-data class DCI(val dri: DRI, val platformDataList: List<PlatformData>) {
- override fun toString() = "$dri[$platformDataList]"
-}
-fun PageNode.platforms(): List<PlatformData> = this.content.flatMap { it.dci.platformDataList }.distinct() // TODO: Override equals???
+fun PageNode.platforms(): List<PlatformData> = this.content.flatMap { it.platforms }.distinct() // TODO: Override equals???
fun PageNode.dfs(predicate: (PageNode) -> Boolean): PageNode? = if (predicate(this)) { this } else { this.children.asSequence().mapNotNull { it.dfs(predicate) }.firstOrNull() }