From 02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33 Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Thu, 31 Aug 2023 20:16:01 +0200 Subject: Enable explicit API mode (#3139) --- .../transformers/documentation/DocumentableMerger.kt | 5 +++-- .../documentation/DocumentableToPageTranslator.kt | 5 +++-- .../documentation/DocumentableTransformer.kt | 4 ++-- .../documentation/PreMergeDocumentableTransformer.kt | 15 +++++++-------- core/src/main/kotlin/transformers/pages/PageCreator.kt | 8 ++++---- .../main/kotlin/transformers/pages/PageTransformer.kt | 4 ++-- .../transformers/pages/PageTransformerBuilders.kt | 17 ++++++++++++----- .../sources/AsyncSourceToDocumentableTranslator.kt | 4 ++-- .../sources/SourceToDocumentableTranslator.kt | 4 ++-- 9 files changed, 37 insertions(+), 29 deletions(-) (limited to 'core/src/main/kotlin/transformers') diff --git a/core/src/main/kotlin/transformers/documentation/DocumentableMerger.kt b/core/src/main/kotlin/transformers/documentation/DocumentableMerger.kt index 9673f2ff..aff1f763 100644 --- a/core/src/main/kotlin/transformers/documentation/DocumentableMerger.kt +++ b/core/src/main/kotlin/transformers/documentation/DocumentableMerger.kt @@ -6,6 +6,7 @@ package org.jetbrains.dokka.transformers.documentation import org.jetbrains.dokka.model.DModule -fun interface DocumentableMerger { - operator fun invoke(modules: Collection): DModule? +public fun interface DocumentableMerger { + public operator fun invoke(modules: Collection): DModule? } + diff --git a/core/src/main/kotlin/transformers/documentation/DocumentableToPageTranslator.kt b/core/src/main/kotlin/transformers/documentation/DocumentableToPageTranslator.kt index fe83be18..ad35ab1d 100644 --- a/core/src/main/kotlin/transformers/documentation/DocumentableToPageTranslator.kt +++ b/core/src/main/kotlin/transformers/documentation/DocumentableToPageTranslator.kt @@ -7,6 +7,7 @@ package org.jetbrains.dokka.transformers.documentation import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.pages.RootPageNode -fun interface DocumentableToPageTranslator { - operator fun invoke(module: DModule): RootPageNode +public fun interface DocumentableToPageTranslator { + public operator fun invoke(module: DModule): RootPageNode } + diff --git a/core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt b/core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt index 9fdf38ba..f680b9f3 100644 --- a/core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt +++ b/core/src/main/kotlin/transformers/documentation/DocumentableTransformer.kt @@ -7,6 +7,6 @@ package org.jetbrains.dokka.transformers.documentation import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.plugability.DokkaContext -fun interface DocumentableTransformer { - operator fun invoke(original: DModule, context: DokkaContext): DModule +public fun interface DocumentableTransformer { + public operator fun invoke(original: DModule, context: DokkaContext): DModule } diff --git a/core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt b/core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt index 06d5ef04..8ae28605 100644 --- a/core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt +++ b/core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt @@ -8,33 +8,32 @@ import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.DokkaConfiguration.PackageOptions import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.model.Documentable +import org.jetbrains.dokka.model.DocumentableSource import org.jetbrains.dokka.model.WithSources -interface PreMergeDocumentableTransformer { - operator fun invoke(modules: List): List +public interface PreMergeDocumentableTransformer { + public operator fun invoke(modules: List): List } -/* Utils */ - /** * It is fair to assume that a given [Documentable] is not merged when seen by the [PreMergeDocumentableTransformer]. * Therefore, it can also be assumed, that there is just a single source set connected to the given [documentable] * @return the single source set associated with this [documentable]. */ -@Suppress("unused") // Receiver is used for scoping this function -fun PreMergeDocumentableTransformer.sourceSet(documentable: Documentable): DokkaSourceSet { +@Suppress("UnusedReceiverParameter") // Receiver is used for scoping this function +public fun PreMergeDocumentableTransformer.sourceSet(documentable: Documentable): DokkaSourceSet { return documentable.sourceSets.single() } /** * @return The [PackageOptions] associated with this documentable, or null */ -fun PreMergeDocumentableTransformer.perPackageOptions(documentable: Documentable): PackageOptions? { +public fun PreMergeDocumentableTransformer.perPackageOptions(documentable: Documentable): PackageOptions? { val packageName = documentable.dri.packageName ?: return null return sourceSet(documentable).perPackageOptions .sortedByDescending { packageOptions -> packageOptions.matchingRegex.length } .firstOrNull { packageOptions -> Regex(packageOptions.matchingRegex).matches(packageName) } } -fun PreMergeDocumentableTransformer.source(documentable: T) where T : Documentable, T : WithSources = +public fun PreMergeDocumentableTransformer.source(documentable: T): DocumentableSource where T : Documentable, T : WithSources = checkNotNull(documentable.sources[sourceSet(documentable)]) diff --git a/core/src/main/kotlin/transformers/pages/PageCreator.kt b/core/src/main/kotlin/transformers/pages/PageCreator.kt index 1dc179f7..8c008f04 100644 --- a/core/src/main/kotlin/transformers/pages/PageCreator.kt +++ b/core/src/main/kotlin/transformers/pages/PageCreator.kt @@ -6,10 +6,10 @@ package org.jetbrains.dokka.transformers.pages import org.jetbrains.dokka.pages.RootPageNode -interface CreationContext +public interface CreationContext -object NoCreationContext : CreationContext +public object NoCreationContext : CreationContext -interface PageCreator { - operator fun invoke(creationContext: T): RootPageNode +public interface PageCreator { + public operator fun invoke(creationContext: T): RootPageNode } diff --git a/core/src/main/kotlin/transformers/pages/PageTransformer.kt b/core/src/main/kotlin/transformers/pages/PageTransformer.kt index cd72818c..b2bbc1d1 100644 --- a/core/src/main/kotlin/transformers/pages/PageTransformer.kt +++ b/core/src/main/kotlin/transformers/pages/PageTransformer.kt @@ -6,6 +6,6 @@ package org.jetbrains.dokka.transformers.pages import org.jetbrains.dokka.pages.RootPageNode -fun interface PageTransformer { - operator fun invoke(input: RootPageNode): RootPageNode +public fun interface PageTransformer { + public operator fun invoke(input: RootPageNode): RootPageNode } diff --git a/core/src/main/kotlin/transformers/pages/PageTransformerBuilders.kt b/core/src/main/kotlin/transformers/pages/PageTransformerBuilders.kt index 2e3732f6..a00c1578 100644 --- a/core/src/main/kotlin/transformers/pages/PageTransformerBuilders.kt +++ b/core/src/main/kotlin/transformers/pages/PageTransformerBuilders.kt @@ -7,14 +7,21 @@ package org.jetbrains.dokka.transformers.pages import org.jetbrains.dokka.pages.PageNode import org.jetbrains.dokka.pages.RootPageNode -fun pageScanner(block: PageNode.() -> Unit) = PageTransformer { input -> input.invokeOnAll(block) as RootPageNode } +public fun pageScanner(block: PageNode.() -> Unit): PageTransformer { + return PageTransformer { input -> input.invokeOnAll(block) as RootPageNode } +} -fun pageMapper(block: PageNode.() -> PageNode) = PageTransformer { input -> input.alterChildren(block) as RootPageNode } +public fun pageMapper(block: PageNode.() -> PageNode): PageTransformer { + return PageTransformer { input -> input.alterChildren(block) as RootPageNode } +} -fun pageStructureTransformer(block: RootPageNode.() -> RootPageNode) = PageTransformer { input -> block(input) } +public fun pageStructureTransformer(block: RootPageNode.() -> RootPageNode): PageTransformer { + return PageTransformer { input -> block(input) } +} -fun PageNode.invokeOnAll(block: PageNode.() -> Unit): PageNode = +public fun PageNode.invokeOnAll(block: PageNode.() -> Unit): PageNode = this.also(block).also { it.children.forEach { it.invokeOnAll(block) } } -fun PageNode.alterChildren(block: PageNode.() -> PageNode): PageNode = +public fun PageNode.alterChildren(block: PageNode.() -> PageNode): PageNode = block(this).modified(children = this.children.map { it.alterChildren(block) }) + diff --git a/core/src/main/kotlin/transformers/sources/AsyncSourceToDocumentableTranslator.kt b/core/src/main/kotlin/transformers/sources/AsyncSourceToDocumentableTranslator.kt index a153759f..f7f45d25 100644 --- a/core/src/main/kotlin/transformers/sources/AsyncSourceToDocumentableTranslator.kt +++ b/core/src/main/kotlin/transformers/sources/AsyncSourceToDocumentableTranslator.kt @@ -10,8 +10,8 @@ import org.jetbrains.dokka.DokkaConfiguration import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.plugability.DokkaContext -interface AsyncSourceToDocumentableTranslator : SourceToDocumentableTranslator { - suspend fun invokeSuspending(sourceSet: DokkaConfiguration.DokkaSourceSet, context: DokkaContext): DModule +public interface AsyncSourceToDocumentableTranslator : SourceToDocumentableTranslator { + public suspend fun invokeSuspending(sourceSet: DokkaConfiguration.DokkaSourceSet, context: DokkaContext): DModule override fun invoke(sourceSet: DokkaConfiguration.DokkaSourceSet, context: DokkaContext): DModule = runBlocking(Dispatchers.Default) { diff --git a/core/src/main/kotlin/transformers/sources/SourceToDocumentableTranslator.kt b/core/src/main/kotlin/transformers/sources/SourceToDocumentableTranslator.kt index 0ba37d40..04f11830 100644 --- a/core/src/main/kotlin/transformers/sources/SourceToDocumentableTranslator.kt +++ b/core/src/main/kotlin/transformers/sources/SourceToDocumentableTranslator.kt @@ -8,6 +8,6 @@ import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.plugability.DokkaContext -fun interface SourceToDocumentableTranslator { - fun invoke(sourceSet: DokkaSourceSet, context: DokkaContext): DModule +public fun interface SourceToDocumentableTranslator { + public fun invoke(sourceSet: DokkaSourceSet, context: DokkaContext): DModule } -- cgit