aboutsummaryrefslogtreecommitdiff
path: root/plugins/all-modules-page/src/main
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 /plugins/all-modules-page/src/main
parent6a181a7a2b03ec263788d137610e86937a57d434 (diff)
downloaddokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.tar.gz
dokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.tar.bz2
dokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.zip
Enable explicit API mode (#3139)
Diffstat (limited to 'plugins/all-modules-page/src/main')
-rw-r--r--plugins/all-modules-page/src/main/kotlin/AllModulesPageGeneration.kt27
-rw-r--r--plugins/all-modules-page/src/main/kotlin/AllModulesPagePlugin.kt30
-rw-r--r--plugins/all-modules-page/src/main/kotlin/ExternalModuleLinkResolver.kt10
-rw-r--r--plugins/all-modules-page/src/main/kotlin/MultimoduleLocationProvider.kt37
-rw-r--r--plugins/all-modules-page/src/main/kotlin/MultimodulePageCreator.kt11
-rw-r--r--plugins/all-modules-page/src/main/kotlin/ResolveLinkCommandHandler.kt2
6 files changed, 67 insertions, 50 deletions
diff --git a/plugins/all-modules-page/src/main/kotlin/AllModulesPageGeneration.kt b/plugins/all-modules-page/src/main/kotlin/AllModulesPageGeneration.kt
index ea009c9e..11d2d32c 100644
--- a/plugins/all-modules-page/src/main/kotlin/AllModulesPageGeneration.kt
+++ b/plugins/all-modules-page/src/main/kotlin/AllModulesPageGeneration.kt
@@ -16,7 +16,7 @@ import org.jetbrains.dokka.templates.TemplatingPlugin
import org.jetbrains.dokka.templates.TemplatingResult
import org.jetbrains.dokka.transformers.pages.CreationContext
-class AllModulesPageGeneration(private val context: DokkaContext) : Generation {
+public class AllModulesPageGeneration(private val context: DokkaContext) : Generation {
private val allModulesPagePlugin by lazy { context.plugin<AllModulesPagePlugin>() }
private val templatingPlugin by lazy { context.plugin<TemplatingPlugin>() }
@@ -44,34 +44,37 @@ class AllModulesPageGeneration(private val context: DokkaContext) : Generation {
runPostActions()
}
- override val generationName = "index page for project"
+ override val generationName: String = "index page for project"
- fun createAllModulesPage(allModulesContext: DefaultAllModulesContext) =
+ public fun createAllModulesPage(allModulesContext: DefaultAllModulesContext): RootPageNode =
allModulesPagePlugin.querySingle { allModulesPageCreator }.invoke(allModulesContext)
- fun transformAllModulesPage(pages: RootPageNode) =
+ public fun transformAllModulesPage(pages: RootPageNode): RootPageNode =
allModulesPagePlugin.query { allModulesPageTransformer }.fold(pages) { acc, t -> t(acc) }
- fun render(transformedPages: RootPageNode) {
+ public fun render(transformedPages: RootPageNode) {
context.single(CoreExtensions.renderer).render(transformedPages)
}
- fun runPostActions() {
+ public fun runPostActions() {
context[CoreExtensions.postActions].forEach { it() }
}
- fun processSubmodules() =
- templatingPlugin.querySingle { submoduleTemplateProcessor }
+ public fun processSubmodules(): DefaultAllModulesContext {
+ return templatingPlugin.querySingle { submoduleTemplateProcessor }
.process(context.configuration.modules)
.let { DefaultAllModulesContext(it) }
+ }
- fun processMultiModule(root: RootPageNode) =
+ public fun processMultiModule(root: RootPageNode) {
templatingPlugin.querySingle { multimoduleTemplateProcessor }.process(root)
+ }
- fun finishProcessingSubmodules() =
+ public fun finishProcessingSubmodules() {
templatingPlugin.query { templateProcessingStrategy }.forEach { it.finish(context.configuration.outputDir) }
+ }
- data class DefaultAllModulesContext(val nonEmptyModules: List<String>) : CreationContext {
- constructor(templating: TemplatingResult) : this(templating.modules)
+ public data class DefaultAllModulesContext(val nonEmptyModules: List<String>) : CreationContext {
+ public constructor(templating: TemplatingResult) : this(templating.modules)
}
}
diff --git a/plugins/all-modules-page/src/main/kotlin/AllModulesPagePlugin.kt b/plugins/all-modules-page/src/main/kotlin/AllModulesPagePlugin.kt
index dec818ba..06202082 100644
--- a/plugins/all-modules-page/src/main/kotlin/AllModulesPagePlugin.kt
+++ b/plugins/all-modules-page/src/main/kotlin/AllModulesPagePlugin.kt
@@ -8,47 +8,47 @@ import org.jetbrains.dokka.CoreExtensions
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.resolvers.local.DokkaLocationProviderFactory
import org.jetbrains.dokka.base.resolvers.local.LocationProviderFactory
-import org.jetbrains.dokka.plugability.DokkaPlugin
-import org.jetbrains.dokka.plugability.DokkaPluginApiPreview
-import org.jetbrains.dokka.plugability.PluginApiPreviewAcknowledgement
+import org.jetbrains.dokka.generation.Generation
+import org.jetbrains.dokka.plugability.*
+import org.jetbrains.dokka.templates.CommandHandler
import org.jetbrains.dokka.templates.TemplatingPlugin
import org.jetbrains.dokka.transformers.pages.PageCreator
import org.jetbrains.dokka.transformers.pages.PageTransformer
-class AllModulesPagePlugin : DokkaPlugin() {
+public class AllModulesPagePlugin : DokkaPlugin() {
- val partialLocationProviderFactory by extensionPoint<LocationProviderFactory>()
- val allModulesPageCreator by extensionPoint<PageCreator<AllModulesPageGeneration.DefaultAllModulesContext>>()
- val allModulesPageTransformer by extensionPoint<PageTransformer>()
- val externalModuleLinkResolver by extensionPoint<ExternalModuleLinkResolver>()
+ public val partialLocationProviderFactory: ExtensionPoint<LocationProviderFactory> by extensionPoint()
+ public val allModulesPageCreator: ExtensionPoint<PageCreator<AllModulesPageGeneration.DefaultAllModulesContext>> by extensionPoint()
+ public val allModulesPageTransformer: ExtensionPoint<PageTransformer> by extensionPoint()
+ public val externalModuleLinkResolver: ExtensionPoint<ExternalModuleLinkResolver> by extensionPoint()
- val allModulesPageCreators by extending {
+ public val allModulesPageCreators: Extension<PageCreator<AllModulesPageGeneration.DefaultAllModulesContext>, *, *> by extending {
allModulesPageCreator providing ::MultimodulePageCreator
}
- val dokkaBase by lazy { plugin<DokkaBase>() }
+ private val dokkaBase: DokkaBase by lazy { plugin<DokkaBase>() }
- val multimoduleLocationProvider by extending {
+ public val multimoduleLocationProvider: Extension<LocationProviderFactory, *, *> by extending {
(dokkaBase.locationProviderFactory
providing MultimoduleLocationProvider::Factory
override plugin<DokkaBase>().locationProvider)
}
- val baseLocationProviderFactory by extending {
+ public val baseLocationProviderFactory: Extension<LocationProviderFactory, *, *> by extending {
partialLocationProviderFactory providing ::DokkaLocationProviderFactory
}
- val allModulesPageGeneration by extending {
+ public val allModulesPageGeneration: Extension<Generation, *, *> by extending {
(CoreExtensions.generation
providing ::AllModulesPageGeneration
override dokkaBase.singleGeneration)
}
- val resolveLinkCommandHandler by extending {
+ public val resolveLinkCommandHandler: Extension<CommandHandler, *, *> by extending {
plugin<TemplatingPlugin>().directiveBasedCommandHandlers providing ::ResolveLinkCommandHandler
}
- val multiModuleLinkResolver by extending {
+ public val multiModuleLinkResolver: Extension<ExternalModuleLinkResolver, *, *> by extending {
externalModuleLinkResolver providing ::DefaultExternalModuleLinkResolver
}
diff --git a/plugins/all-modules-page/src/main/kotlin/ExternalModuleLinkResolver.kt b/plugins/all-modules-page/src/main/kotlin/ExternalModuleLinkResolver.kt
index f7b7cac4..da747bda 100644
--- a/plugins/all-modules-page/src/main/kotlin/ExternalModuleLinkResolver.kt
+++ b/plugins/all-modules-page/src/main/kotlin/ExternalModuleLinkResolver.kt
@@ -16,12 +16,14 @@ import org.jetbrains.dokka.plugability.query
import java.io.File
import java.net.URL
-interface ExternalModuleLinkResolver {
- fun resolve(dri: DRI, fileContext: File): String?
- fun resolveLinkToModuleIndex(moduleName: String): String?
+public interface ExternalModuleLinkResolver {
+ public fun resolve(dri: DRI, fileContext: File): String?
+ public fun resolveLinkToModuleIndex(moduleName: String): String?
}
-class DefaultExternalModuleLinkResolver(val context: DokkaContext) : ExternalModuleLinkResolver {
+public class DefaultExternalModuleLinkResolver(
+ public val context: DokkaContext
+) : ExternalModuleLinkResolver {
private val elpFactory = context.plugin<DokkaBase>().query { externalLocationProviderFactory }
private val externalDocumentations by lazy(::setupExternalDocumentations)
private val elps by lazy {
diff --git a/plugins/all-modules-page/src/main/kotlin/MultimoduleLocationProvider.kt b/plugins/all-modules-page/src/main/kotlin/MultimoduleLocationProvider.kt
index cfd0d675..b0fa13d0 100644
--- a/plugins/all-modules-page/src/main/kotlin/MultimoduleLocationProvider.kt
+++ b/plugins/all-modules-page/src/main/kotlin/MultimoduleLocationProvider.kt
@@ -6,6 +6,7 @@ package org.jetbrains.dokka.allModulesPage
import org.jetbrains.dokka.allModulesPage.MultimodulePageCreator.Companion.MULTIMODULE_PACKAGE_PLACEHOLDER
import org.jetbrains.dokka.base.resolvers.local.DokkaBaseLocationProvider
+import org.jetbrains.dokka.base.resolvers.local.LocationProvider
import org.jetbrains.dokka.base.resolvers.local.LocationProviderFactory
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.DisplaySourceSet
@@ -16,9 +17,10 @@ import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.plugability.plugin
import org.jetbrains.dokka.plugability.querySingle
-open class MultimoduleLocationProvider(private val root: RootPageNode, dokkaContext: DokkaContext,
- val extension: String = ".html") :
- DokkaBaseLocationProvider(root, dokkaContext) {
+public open class MultimoduleLocationProvider(
+ private val root: RootPageNode, dokkaContext: DokkaContext,
+ public val extension: String = ".html"
+) : DokkaBaseLocationProvider(root, dokkaContext) {
private val defaultLocationProvider =
dokkaContext.plugin<AllModulesPagePlugin>().querySingle { partialLocationProviderFactory }
@@ -26,21 +28,32 @@ open class MultimoduleLocationProvider(private val root: RootPageNode, dokkaCont
private val externalModuleLinkResolver =
dokkaContext.plugin<AllModulesPagePlugin>().querySingle { externalModuleLinkResolver }
- override fun resolve(dri: DRI, sourceSets: Set<DisplaySourceSet>, context: PageNode?) =
- if (dri == MultimodulePageCreator.MULTIMODULE_ROOT_DRI) pathToRoot(root) + "index"
- else dri.takeIf { it.packageName == MULTIMODULE_PACKAGE_PLACEHOLDER }?.classNames
- ?.let(externalModuleLinkResolver::resolveLinkToModuleIndex)
+ override fun resolve(dri: DRI, sourceSets: Set<DisplaySourceSet>, context: PageNode?): String? {
+ return if (dri == MultimodulePageCreator.MULTIMODULE_ROOT_DRI) {
+ pathToRoot(root) + "index"
+ } else {
+ dri.takeIf { it.packageName == MULTIMODULE_PACKAGE_PLACEHOLDER }
+ ?.classNames
+ ?.let(externalModuleLinkResolver::resolveLinkToModuleIndex)
+ }
+ }
- override fun resolve(node: PageNode, context: PageNode?, skipExtension: Boolean) =
- if (node is ContentPage && MultimodulePageCreator.MULTIMODULE_ROOT_DRI in node.dri) pathToRoot(root) + "index" + if (!skipExtension) extension else ""
- else defaultLocationProvider.resolve(node, context, skipExtension)
+ override fun resolve(node: PageNode, context: PageNode?, skipExtension: Boolean): String? {
+ return if (node is ContentPage && MultimodulePageCreator.MULTIMODULE_ROOT_DRI in node.dri) {
+ pathToRoot(root) + "index" + if (!skipExtension) extension else ""
+ } else {
+ defaultLocationProvider.resolve(node, context, skipExtension)
+ }
+ }
override fun pathToRoot(from: PageNode): String = defaultLocationProvider.pathToRoot(from)
override fun ancestors(node: PageNode): List<PageNode> = listOf(root)
- class Factory(private val context: DokkaContext) : LocationProviderFactory {
- override fun getLocationProvider(pageNode: RootPageNode) =
+ public class Factory(
+ private val context: DokkaContext
+ ) : LocationProviderFactory {
+ override fun getLocationProvider(pageNode: RootPageNode): LocationProvider =
MultimoduleLocationProvider(pageNode, context)
}
}
diff --git a/plugins/all-modules-page/src/main/kotlin/MultimodulePageCreator.kt b/plugins/all-modules-page/src/main/kotlin/MultimodulePageCreator.kt
index 6fbec587..7b832d21 100644
--- a/plugins/all-modules-page/src/main/kotlin/MultimodulePageCreator.kt
+++ b/plugins/all-modules-page/src/main/kotlin/MultimodulePageCreator.kt
@@ -25,11 +25,9 @@ import org.jetbrains.dokka.utilities.DokkaLogger
import org.jetbrains.dokka.analysis.kotlin.internal.InternalKotlinAnalysisPlugin
import java.io.File
-class MultimodulePageCreator(
+public class MultimodulePageCreator(
private val context: DokkaContext,
) : PageCreator<AllModulesPageGeneration.DefaultAllModulesContext> {
- private val logger: DokkaLogger = context.logger
-
private val commentsConverter by lazy { context.plugin<DokkaBase>().querySingle { commentsToContentConverter } }
private val signatureProvider by lazy { context.plugin<DokkaBase>().querySingle { signatureProvider } }
private val moduleDocumentationReader by lazy { context.plugin<InternalKotlinAnalysisPlugin>().querySingle { moduleAndPackageDocumentationReader } }
@@ -109,8 +107,9 @@ class MultimodulePageCreator(
else firstChildParagraph
}
- companion object {
- const val MULTIMODULE_PACKAGE_PLACEHOLDER = ".ext"
- val MULTIMODULE_ROOT_DRI = DRI(packageName = MULTIMODULE_PACKAGE_PLACEHOLDER, classNames = "allModules")
+ public companion object {
+ public const val MULTIMODULE_PACKAGE_PLACEHOLDER: String = ".ext"
+ public val MULTIMODULE_ROOT_DRI: DRI =
+ DRI(packageName = MULTIMODULE_PACKAGE_PLACEHOLDER, classNames = "allModules")
}
}
diff --git a/plugins/all-modules-page/src/main/kotlin/ResolveLinkCommandHandler.kt b/plugins/all-modules-page/src/main/kotlin/ResolveLinkCommandHandler.kt
index 9720199c..f6d34271 100644
--- a/plugins/all-modules-page/src/main/kotlin/ResolveLinkCommandHandler.kt
+++ b/plugins/all-modules-page/src/main/kotlin/ResolveLinkCommandHandler.kt
@@ -15,7 +15,7 @@ import org.jsoup.nodes.Element
import org.jsoup.parser.Tag
import java.io.File
-class ResolveLinkCommandHandler(context: DokkaContext) : CommandHandler {
+public class ResolveLinkCommandHandler(context: DokkaContext) : CommandHandler {
private val externalModuleLinkResolver =
context.plugin<AllModulesPagePlugin>().querySingle { externalModuleLinkResolver }