aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/pages
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2023-08-31 20:16:01 +0200
committerGitHub <noreply@github.com>2023-08-31 20:16:01 +0200
commit02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33 (patch)
tree66f6d6f089a93b863bf1144666491eca6729ad05 /core/src/main/kotlin/pages
parent6a181a7a2b03ec263788d137610e86937a57d434 (diff)
downloaddokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.tar.gz
dokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.tar.bz2
dokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.zip
Enable explicit API mode (#3139)
Diffstat (limited to 'core/src/main/kotlin/pages')
-rw-r--r--core/src/main/kotlin/pages/ContentNodes.kt86
-rw-r--r--core/src/main/kotlin/pages/PageNodes.kt48
-rw-r--r--core/src/main/kotlin/pages/Pages.kt10
-rw-r--r--core/src/main/kotlin/pages/RendererSpecificPage.kt37
-rw-r--r--core/src/main/kotlin/pages/contentNodeProperties.kt17
-rw-r--r--core/src/main/kotlin/pages/utils.kt4
6 files changed, 104 insertions, 98 deletions
diff --git a/core/src/main/kotlin/pages/ContentNodes.kt b/core/src/main/kotlin/pages/ContentNodes.kt
index 87178277..96f43205 100644
--- a/core/src/main/kotlin/pages/ContentNodes.kt
+++ b/core/src/main/kotlin/pages/ContentNodes.kt
@@ -10,25 +10,25 @@ import org.jetbrains.dokka.model.WithChildren
import org.jetbrains.dokka.model.properties.PropertyContainer
import org.jetbrains.dokka.model.properties.WithExtraProperties
-data class DCI(val dri: Set<DRI>, val kind: Kind) {
- override fun toString() = "$dri[$kind]"
+public data class DCI(val dri: Set<DRI>, val kind: Kind) {
+ override fun toString(): String = "$dri[$kind]"
}
-interface ContentNode : WithExtraProperties<ContentNode>, WithChildren<ContentNode> {
- val dci: DCI
- val sourceSets: Set<DisplaySourceSet>
- val style: Set<Style>
+public interface ContentNode : WithExtraProperties<ContentNode>, WithChildren<ContentNode> {
+ public val dci: DCI
+ public val sourceSets: Set<DisplaySourceSet>
+ public val style: Set<Style>
- fun hasAnyContent(): Boolean
+ public fun hasAnyContent(): Boolean
- fun withSourceSets(sourceSets: Set<DisplaySourceSet>): ContentNode
+ public fun withSourceSets(sourceSets: Set<DisplaySourceSet>): ContentNode
override val children: List<ContentNode>
get() = emptyList()
}
/** Simple text */
-data class ContentText(
+public data class ContentText(
val text: String,
override val dci: DCI,
override val sourceSets: Set<DisplaySourceSet>,
@@ -40,7 +40,7 @@ data class ContentText(
override fun hasAnyContent(): Boolean = text.isNotBlank()
}
-data class ContentBreakLine(
+public data class ContentBreakLine(
override val sourceSets: Set<DisplaySourceSet>,
override val dci: DCI = DCI(emptySet(), ContentKind.Empty),
override val style: Set<Style> = emptySet(),
@@ -52,7 +52,7 @@ data class ContentBreakLine(
}
/** Headers */
-data class ContentHeader(
+public data class ContentHeader(
override val children: List<ContentNode>,
val level: Int,
override val dci: DCI,
@@ -60,7 +60,7 @@ data class ContentHeader(
override val style: Set<Style>,
override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
) : ContentComposite {
- constructor(level: Int, c: ContentComposite) : this(c.children, level, c.dci, c.sourceSets, c.style, c.extra)
+ public constructor(level: Int, c: ContentComposite) : this(c.children, level, c.dci, c.sourceSets, c.style, c.extra)
override fun withNewExtras(newExtras: PropertyContainer<ContentNode>): ContentHeader = copy(extra = newExtras)
@@ -71,10 +71,10 @@ data class ContentHeader(
copy(sourceSets = sourceSets)
}
-interface ContentCode : ContentComposite
+public interface ContentCode : ContentComposite
/** Code blocks */
-data class ContentCodeBlock(
+public data class ContentCodeBlock(
override val children: List<ContentNode>,
val language: String,
override val dci: DCI,
@@ -92,7 +92,7 @@ data class ContentCodeBlock(
}
-data class ContentCodeInline(
+public data class ContentCodeInline(
override val children: List<ContentNode>,
val language: String,
override val dci: DCI,
@@ -111,10 +111,10 @@ data class ContentCodeInline(
}
/** Union type replacement */
-interface ContentLink : ContentComposite
+public interface ContentLink : ContentComposite
/** All links to classes, packages, etc. that have te be resolved */
-data class ContentDRILink(
+public data class ContentDRILink(
override val children: List<ContentNode>,
val address: DRI,
override val dci: DCI,
@@ -133,7 +133,7 @@ data class ContentDRILink(
}
/** All links that do not need to be resolved */
-data class ContentResolvedLink(
+public data class ContentResolvedLink(
override val children: List<ContentNode>,
val address: String,
override val dci: DCI,
@@ -152,7 +152,7 @@ data class ContentResolvedLink(
}
/** Embedded resources like images */
-data class ContentEmbeddedResource(
+public data class ContentEmbeddedResource(
override val children: List<ContentNode> = emptyList(),
val address: String,
val altText: String?,
@@ -172,18 +172,18 @@ data class ContentEmbeddedResource(
}
/** Logical grouping of [ContentNode]s */
-interface ContentComposite : ContentNode {
+public interface ContentComposite : ContentNode {
override val children: List<ContentNode> // overwrite to make it abstract once again
override val sourceSets: Set<DisplaySourceSet> get() = children.flatMap { it.sourceSets }.toSet()
- fun transformChildren(transformer: (ContentNode) -> ContentNode): ContentComposite
+ public fun transformChildren(transformer: (ContentNode) -> ContentNode): ContentComposite
override fun hasAnyContent(): Boolean = children.any { it.hasAnyContent() }
}
/** Tables */
-data class ContentTable(
+public data class ContentTable(
val header: List<ContentGroup>,
val caption: ContentGroup? = null,
override val children: List<ContentGroup>,
@@ -203,7 +203,7 @@ data class ContentTable(
}
/** Lists */
-data class ContentList(
+public data class ContentList(
override val children: List<ContentNode>,
val ordered: Boolean,
override val dci: DCI,
@@ -221,7 +221,7 @@ data class ContentList(
}
/** Default group, eg. for blocks of Functions, Properties, etc. **/
-data class ContentGroup(
+public data class ContentGroup(
override val children: List<ContentNode>,
override val dci: DCI,
override val sourceSets: Set<DisplaySourceSet>,
@@ -240,7 +240,7 @@ data class ContentGroup(
/**
* @property groupID is used for finding and copying [ContentDivergentInstance]s when merging [ContentPage]s
*/
-data class ContentDivergentGroup(
+public data class ContentDivergentGroup(
override val children: List<ContentDivergentInstance>,
override val dci: DCI,
override val style: Set<Style>,
@@ -248,7 +248,7 @@ data class ContentDivergentGroup(
val groupID: GroupID,
val implicitlySourceSetHinted: Boolean = true
) : ContentComposite {
- data class GroupID(val name: String)
+ public data class GroupID(val name: String)
override val sourceSets: Set<DisplaySourceSet>
get() = children.flatMap { it.sourceSets }.distinct().toSet()
@@ -263,7 +263,7 @@ data class ContentDivergentGroup(
}
/** Instance of a divergent content */
-data class ContentDivergentInstance(
+public data class ContentDivergentInstance(
val before: ContentNode?,
val divergent: ContentNode,
val after: ContentNode?,
@@ -290,11 +290,11 @@ data class ContentDivergentInstance(
}
-data class PlatformHintedContent(
+public data class PlatformHintedContent(
val inner: ContentNode,
override val sourceSets: Set<DisplaySourceSet>
) : ContentComposite {
- override val children = listOf(inner)
+ override val children: List<ContentNode> = listOf(inner)
override val dci: DCI
get() = inner.dci
@@ -305,7 +305,7 @@ data class PlatformHintedContent(
override val style: Set<Style>
get() = inner.style
- override fun withNewExtras(newExtras: PropertyContainer<ContentNode>) =
+ override fun withNewExtras(newExtras: PropertyContainer<ContentNode>): ContentNode =
throw UnsupportedOperationException("This method should not be called on this PlatformHintedContent")
override fun transformChildren(transformer: (ContentNode) -> ContentNode): PlatformHintedContent =
@@ -316,14 +316,14 @@ data class PlatformHintedContent(
}
-interface Style
-interface Kind
+public interface Style
+public interface Kind
/**
* [ContentKind] represents a grouping of content of one kind that can can be rendered
* as part of a composite page (one tab/block within a class's page, for instance).
*/
-enum class ContentKind : Kind {
+public enum class ContentKind : Kind {
/**
* Marks all sorts of signatures. Can contain sub-kinds marked as [SymbolContentKind]
@@ -344,7 +344,7 @@ enum class ContentKind : Kind {
*/
Deprecation;
- companion object {
+ public companion object {
private val platformTagged =
setOf(
Constructors,
@@ -358,14 +358,14 @@ enum class ContentKind : Kind {
Extensions
)
- fun shouldBePlatformTagged(kind: Kind): Boolean = kind in platformTagged
+ public fun shouldBePlatformTagged(kind: Kind): Boolean = kind in platformTagged
}
}
/**
* Content kind for [ContentKind.Symbol] content, which is essentially about signatures
*/
-enum class SymbolContentKind : Kind {
+public enum class SymbolContentKind : Kind {
/**
* Marks constructor/function parameters, everything in-between parentheses.
*
@@ -385,17 +385,17 @@ enum class SymbolContentKind : Kind {
Parameter,
}
-enum class TokenStyle : Style {
+public enum class TokenStyle : Style {
Keyword, Punctuation, Function, Operator, Annotation, Number, String, Boolean, Constant
}
-enum class TextStyle : Style {
+public enum class TextStyle : Style {
Bold, Italic, Strong, Strikethrough, Paragraph,
Block, Span, Monospace, Indented, Cover, UnderCoverText, BreakableAfter, Breakable, InlineComment, Quotation,
FloatingRight, Var, Underlined
}
-enum class ContentStyle : Style {
+public enum class ContentStyle : Style {
RowTitle,
/**
* The style is used only for HTML. It is applied only for [ContentGroup].
@@ -407,7 +407,7 @@ enum class ContentStyle : Style {
Wrapped, Indented, KDocTag, Footnote
}
-enum class ListStyle : Style {
+public enum class ListStyle : Style {
/**
* Represents a list of groups of [DescriptionTerm] and [DescriptionDetails].
* Common uses for this element are to implement a glossary or to display
@@ -429,8 +429,8 @@ enum class ListStyle : Style {
DescriptionDetails
}
-object CommentTable : Style
+public object CommentTable : Style
-object MultimoduleTable : Style
+public object MultimoduleTable : Style
-fun ContentNode.hasStyle(style: Style) = this.style.contains(style)
+public fun ContentNode.hasStyle(style: Style): Boolean = this.style.contains(style)
diff --git a/core/src/main/kotlin/pages/PageNodes.kt b/core/src/main/kotlin/pages/PageNodes.kt
index 8233464c..cfaf2347 100644
--- a/core/src/main/kotlin/pages/PageNodes.kt
+++ b/core/src/main/kotlin/pages/PageNodes.kt
@@ -9,28 +9,28 @@ import org.jetbrains.dokka.model.Documentable
import org.jetbrains.dokka.model.WithChildren
import java.util.*
-interface PageNode : WithChildren<PageNode> {
- val name: String
+public interface PageNode : WithChildren<PageNode> {
+ public val name: String
override val children: List<PageNode>
- fun modified(
+ public fun modified(
name: String = this.name,
children: List<PageNode> = this.children
): PageNode
}
-interface ContentPage : PageNode {
- val content: ContentNode
- val dri: Set<DRI>
- val embeddedResources: List<String>
+public interface ContentPage : PageNode {
+ public val content: ContentNode
+ public val dri: Set<DRI>
+ public val embeddedResources: List<String>
@Deprecated("Deprecated. Remove its usages from your code.",
ReplaceWith("this.documentables.firstOrNull()")
)
- val documentable: Documentable?
+ public val documentable: Documentable?
get() = if (this is WithDocumentables) this.documentables.firstOrNull() else null
- fun modified(
+ public fun modified(
name: String = this.name,
content: ContentNode = this.content,
dri: Set<DRI> = this.dri,
@@ -39,12 +39,14 @@ interface ContentPage : PageNode {
): ContentPage
}
-interface WithDocumentables {
- val documentables: List<Documentable>
+public interface WithDocumentables {
+ public val documentables: List<Documentable>
}
-abstract class RootPageNode(val forceTopLevelName: Boolean = false) : PageNode {
- val parentMap: Map<PageNode, PageNode> by lazy {
+public abstract class RootPageNode(
+ public val forceTopLevelName: Boolean = false
+) : PageNode {
+ public val parentMap: Map<PageNode, PageNode> by lazy {
IdentityHashMap<PageNode, PageNode>().apply {
fun process(parent: PageNode) {
parent.children.forEach { child ->
@@ -56,10 +58,10 @@ abstract class RootPageNode(val forceTopLevelName: Boolean = false) : PageNode {
}
}
- fun transformPageNodeTree(operation: (PageNode) -> PageNode) =
+ public fun transformPageNodeTree(operation: (PageNode) -> PageNode): RootPageNode =
this.transformNode(operation) as RootPageNode
- fun transformContentPagesTree(operation: (ContentPage) -> ContentPage) = transformPageNodeTree {
+ public fun transformContentPagesTree(operation: (ContentPage) -> ContentPage): RootPageNode = transformPageNodeTree {
if (it is ContentPage) operation(it) else it
}
@@ -74,7 +76,7 @@ abstract class RootPageNode(val forceTopLevelName: Boolean = false) : PageNode {
): RootPageNode
}
-class ModulePageNode(
+public class ModulePageNode(
override val name: String,
override val content: ContentNode,
override val documentables: List<Documentable> = listOf(),
@@ -97,7 +99,7 @@ class ModulePageNode(
else ModulePageNode(name, content, documentables, children, embeddedResources)
}
-class PackagePageNode(
+public class PackagePageNode(
override val name: String,
override val content: ContentNode,
override val dri: Set<DRI>,
@@ -124,7 +126,7 @@ class PackagePageNode(
else PackagePageNode(name, content, dri, documentables, children, embeddedResources)
}
-class ClasslikePageNode(
+public class ClasslikePageNode(
override val name: String,
override val content: ContentNode,
override val dri: Set<DRI>,
@@ -146,7 +148,7 @@ class ClasslikePageNode(
else ClasslikePageNode(name, content, dri, documentables, children, embeddedResources)
}
-class MemberPageNode(
+public class MemberPageNode(
override val name: String,
override val content: ContentNode,
override val dri: Set<DRI>,
@@ -169,12 +171,12 @@ class MemberPageNode(
}
-class MultimoduleRootPageNode(
+public class MultimoduleRootPageNode(
override val dri: Set<DRI>,
override val content: ContentNode,
override val embeddedResources: List<String> = emptyList()
) : RootPageNode(forceTopLevelName = true), MultimoduleRootPage {
- override val name = "All modules"
+ override val name: String = "All modules"
override val children: List<PageNode> = emptyList()
@@ -187,12 +189,12 @@ class MultimoduleRootPageNode(
dri: Set<DRI>,
embeddedResources: List<String>,
children: List<PageNode>
- ) =
+ ): ContentPage =
if (name == this.name && content === this.content && embeddedResources === this.embeddedResources && children shallowEq this.children) this
else MultimoduleRootPageNode(dri, content, embeddedResources)
}
-inline fun <reified T : PageNode> PageNode.children() = children.filterIsInstance<T>()
+public inline fun <reified T : PageNode> PageNode.children(): List<T> = children.filterIsInstance<T>()
private infix fun <T> List<T>.shallowEq(other: List<T>) =
this === other || (this.size == other.size && (this zip other).all { (a, b) -> a === b })
diff --git a/core/src/main/kotlin/pages/Pages.kt b/core/src/main/kotlin/pages/Pages.kt
index ae305de7..0bf225c9 100644
--- a/core/src/main/kotlin/pages/Pages.kt
+++ b/core/src/main/kotlin/pages/Pages.kt
@@ -4,12 +4,12 @@
package org.jetbrains.dokka.pages
-interface MultimoduleRootPage : ContentPage
+public interface MultimoduleRootPage : ContentPage
-interface ModulePage : ContentPage, WithDocumentables
+public interface ModulePage : ContentPage, WithDocumentables
-interface PackagePage : ContentPage, WithDocumentables
+public interface PackagePage : ContentPage, WithDocumentables
-interface ClasslikePage : ContentPage, WithDocumentables
+public interface ClasslikePage : ContentPage, WithDocumentables
-interface MemberPage : ContentPage, WithDocumentables
+public interface MemberPage : ContentPage, WithDocumentables
diff --git a/core/src/main/kotlin/pages/RendererSpecificPage.kt b/core/src/main/kotlin/pages/RendererSpecificPage.kt
index c8661ae5..701886b7 100644
--- a/core/src/main/kotlin/pages/RendererSpecificPage.kt
+++ b/core/src/main/kotlin/pages/RendererSpecificPage.kt
@@ -9,14 +9,14 @@ import org.jetbrains.dokka.model.DisplaySourceSet
import org.jetbrains.dokka.renderers.Renderer
import kotlin.reflect.KClass
-fun interface DriResolver: (DRI, Set<DisplaySourceSet>) -> String?
-fun interface PageResolver: (PageNode, PageNode?) -> String?
+public fun interface DriResolver: (DRI, Set<DisplaySourceSet>) -> String?
+public fun interface PageResolver: (PageNode, PageNode?) -> String?
-interface RendererSpecificPage : PageNode {
- val strategy: RenderingStrategy
+public interface RendererSpecificPage : PageNode {
+ public val strategy: RenderingStrategy
}
-class RendererSpecificRootPage(
+public class RendererSpecificRootPage(
override val name: String,
override val children: List<PageNode>,
override val strategy: RenderingStrategy
@@ -25,7 +25,7 @@ class RendererSpecificRootPage(
RendererSpecificRootPage(name, children, strategy)
}
-class RendererSpecificResourcePage(
+public class RendererSpecificResourcePage(
override val name: String,
override val children: List<PageNode>,
override val strategy: RenderingStrategy
@@ -34,18 +34,19 @@ class RendererSpecificResourcePage(
RendererSpecificResourcePage(name, children, strategy)
}
-sealed class RenderingStrategy {
- class Callback(val instructions: Renderer.(PageNode) -> String): RenderingStrategy()
- data class Copy(val from: String) : RenderingStrategy()
- data class Write(val text: String) : RenderingStrategy()
- data class DriLocationResolvableWrite(val contentToResolve: (DriResolver) -> String) : RenderingStrategy()
- data class PageLocationResolvableWrite(val contentToResolve: (PageResolver) -> String) : RenderingStrategy()
- object DoNothing : RenderingStrategy()
-
- companion object {
- inline operator fun <reified T: Renderer> invoke(crossinline instructions: T.(PageNode) -> String) =
- Callback { if (this is T) instructions(it) else throw WrongRendererTypeException(T::class) }
+public sealed class RenderingStrategy {
+ public class Callback(public val instructions: Renderer.(PageNode) -> String): RenderingStrategy()
+ public data class Copy(val from: String) : RenderingStrategy()
+ public data class Write(val text: String) : RenderingStrategy()
+ public data class DriLocationResolvableWrite(val contentToResolve: (DriResolver) -> String) : RenderingStrategy()
+ public data class PageLocationResolvableWrite(val contentToResolve: (PageResolver) -> String) : RenderingStrategy()
+ public object DoNothing : RenderingStrategy()
+
+ public companion object {
+ public inline operator fun <reified T: Renderer> invoke(crossinline instructions: T.(PageNode) -> String): RenderingStrategy {
+ return Callback { if (this is T) instructions(it) else throw WrongRendererTypeException(T::class) }
+ }
}
}
-data class WrongRendererTypeException(val expectedType: KClass<*>): Exception()
+public data class WrongRendererTypeException(val expectedType: KClass<*>): Exception()
diff --git a/core/src/main/kotlin/pages/contentNodeProperties.kt b/core/src/main/kotlin/pages/contentNodeProperties.kt
index 0a400165..64f19572 100644
--- a/core/src/main/kotlin/pages/contentNodeProperties.kt
+++ b/core/src/main/kotlin/pages/contentNodeProperties.kt
@@ -6,29 +6,32 @@ package org.jetbrains.dokka.pages
import org.jetbrains.dokka.model.properties.ExtraProperty
-class SimpleAttr(val extraKey: String, val extraValue: String) : ExtraProperty<ContentNode> {
- data class SimpleAttrKey(val key: String) : ExtraProperty.Key<ContentNode, SimpleAttr>
+public class SimpleAttr(
+ public val extraKey: String,
+ public val extraValue: String
+) : ExtraProperty<ContentNode> {
+ public data class SimpleAttrKey(val key: String) : ExtraProperty.Key<ContentNode, SimpleAttr>
override val key: ExtraProperty.Key<ContentNode, SimpleAttr> = SimpleAttrKey(extraKey)
}
-enum class BasicTabbedContentType : TabbedContentType {
+public enum class BasicTabbedContentType : TabbedContentType {
TYPE, CONSTRUCTOR, FUNCTION, PROPERTY, ENTRY, EXTENSION_PROPERTY, EXTENSION_FUNCTION
}
/**
* It is used only to mark content for tabs in HTML format
*/
-interface TabbedContentType
+public interface TabbedContentType
/**
* @see TabbedContentType
*/
-class TabbedContentTypeExtra(val value: TabbedContentType) : ExtraProperty<ContentNode> {
- companion object : ExtraProperty.Key<ContentNode, TabbedContentTypeExtra>
+public class TabbedContentTypeExtra(public val value: TabbedContentType) : ExtraProperty<ContentNode> {
+ public companion object : ExtraProperty.Key<ContentNode, TabbedContentTypeExtra>
override val key: ExtraProperty.Key<ContentNode, TabbedContentTypeExtra> = TabbedContentTypeExtra
}
-object HtmlContent : ExtraProperty<ContentNode>, ExtraProperty.Key<ContentNode, HtmlContent> {
+public object HtmlContent : ExtraProperty<ContentNode>, ExtraProperty.Key<ContentNode, HtmlContent> {
override val key: ExtraProperty.Key<ContentNode, *> = this
}
diff --git a/core/src/main/kotlin/pages/utils.kt b/core/src/main/kotlin/pages/utils.kt
index 6aa0b5f7..6c416e24 100644
--- a/core/src/main/kotlin/pages/utils.kt
+++ b/core/src/main/kotlin/pages/utils.kt
@@ -6,10 +6,10 @@ package org.jetbrains.dokka.pages
import kotlin.reflect.KClass
-inline fun <reified T : ContentNode, R : ContentNode> R.mapTransform(noinline operation: (T) -> T): R =
+public inline fun <reified T : ContentNode, R : ContentNode> R.mapTransform(noinline operation: (T) -> T): R =
mapTransform(T::class, operation)
-inline fun <reified T : ContentNode, R : ContentNode> R.recursiveMapTransform(noinline operation: (T) -> T): R =
+public inline fun <reified T : ContentNode, R : ContentNode> R.recursiveMapTransform(noinline operation: (T) -> T): R =
recursiveMapTransform(T::class, operation)
@PublishedApi