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) --- plugins/gfm/api/gfm.api | 3 +-- .../GfmTemplateProcessingPlugin.kt | 13 +++++++------ .../GfmTemplateProcessingStrategy.kt | 4 +++- .../kotlin/org/jetbrains/dokka/gfm/GfmPlugin.kt | 20 ++++++++++---------- .../kotlin/org/jetbrains/dokka/gfm/gfmTemplating.kt | 21 ++++++++++++++------- .../dokka/gfm/location/MarkdownLocationProvider.kt | 7 ++++--- .../dokka/gfm/renderer/BriefCommentPreprocessor.kt | 20 +++++++++++--------- .../dokka/gfm/renderer/CommonmarkRenderer.kt | 5 +++-- 8 files changed, 53 insertions(+), 40 deletions(-) (limited to 'plugins/gfm') diff --git a/plugins/gfm/api/gfm.api b/plugins/gfm/api/gfm.api index b6970211..f77c9b68 100644 --- a/plugins/gfm/api/gfm.api +++ b/plugins/gfm/api/gfm.api @@ -30,8 +30,7 @@ public final class org/jetbrains/dokka/gfm/location/MarkdownLocationProvider : o public final class org/jetbrains/dokka/gfm/location/MarkdownLocationProvider$Factory : org/jetbrains/dokka/base/resolvers/local/LocationProviderFactory { public fun (Lorg/jetbrains/dokka/plugability/DokkaContext;)V - public synthetic fun getLocationProvider (Lorg/jetbrains/dokka/pages/RootPageNode;)Lorg/jetbrains/dokka/base/resolvers/local/LocationProvider; - public fun getLocationProvider (Lorg/jetbrains/dokka/pages/RootPageNode;)Lorg/jetbrains/dokka/gfm/location/MarkdownLocationProvider; + public fun getLocationProvider (Lorg/jetbrains/dokka/pages/RootPageNode;)Lorg/jetbrains/dokka/base/resolvers/local/LocationProvider; } public final class org/jetbrains/dokka/gfm/renderer/BriefCommentPreprocessor : org/jetbrains/dokka/transformers/pages/PageTransformer { diff --git a/plugins/gfm/gfm-template-processing/src/main/kotlin/org/jetbrains/dokka/gfm/templateProcessing/GfmTemplateProcessingPlugin.kt b/plugins/gfm/gfm-template-processing/src/main/kotlin/org/jetbrains/dokka/gfm/templateProcessing/GfmTemplateProcessingPlugin.kt index 4bb9cf63..fd2af274 100644 --- a/plugins/gfm/gfm-template-processing/src/main/kotlin/org/jetbrains/dokka/gfm/templateProcessing/GfmTemplateProcessingPlugin.kt +++ b/plugins/gfm/gfm-template-processing/src/main/kotlin/org/jetbrains/dokka/gfm/templateProcessing/GfmTemplateProcessingPlugin.kt @@ -7,33 +7,34 @@ package org.jetbrains.dokka.gfm.templateProcessing import org.jetbrains.dokka.allModulesPage.AllModulesPagePlugin import org.jetbrains.dokka.allModulesPage.MultimoduleLocationProvider import org.jetbrains.dokka.base.DokkaBase +import org.jetbrains.dokka.base.resolvers.local.LocationProviderFactory import org.jetbrains.dokka.gfm.GfmPlugin import org.jetbrains.dokka.gfm.location.MarkdownLocationProvider import org.jetbrains.dokka.plugability.DokkaPlugin import org.jetbrains.dokka.plugability.DokkaPluginApiPreview +import org.jetbrains.dokka.plugability.Extension import org.jetbrains.dokka.plugability.PluginApiPreviewAcknowledgement +import org.jetbrains.dokka.templates.TemplateProcessingStrategy import org.jetbrains.dokka.templates.TemplatingPlugin -class GfmTemplateProcessingPlugin : DokkaPlugin() { +public class GfmTemplateProcessingPlugin : DokkaPlugin() { private val allModulesPagePlugin by lazy { plugin() } private val templateProcessingPlugin by lazy { plugin() } - private val gfmPlugin by lazy { plugin() } - private val dokkaBase by lazy { plugin()} - val gfmTemplateProcessingStrategy by extending { + public val gfmTemplateProcessingStrategy: Extension by extending { (templateProcessingPlugin.templateProcessingStrategy providing ::GfmTemplateProcessingStrategy order { before(templateProcessingPlugin.fallbackProcessingStrategy) }) } - val gfmLocationProvider by extending { + public val gfmLocationProvider: Extension by extending { dokkaBase.locationProviderFactory providing MultimoduleLocationProvider::Factory override listOf(gfmPlugin.locationProvider, allModulesPagePlugin.multimoduleLocationProvider) } - val gfmPartialLocationProvider by extending { + public val gfmPartialLocationProvider: Extension by extending { allModulesPagePlugin.partialLocationProviderFactory providing MarkdownLocationProvider::Factory override allModulesPagePlugin.baseLocationProviderFactory } diff --git a/plugins/gfm/gfm-template-processing/src/main/kotlin/org/jetbrains/dokka/gfm/templateProcessing/GfmTemplateProcessingStrategy.kt b/plugins/gfm/gfm-template-processing/src/main/kotlin/org/jetbrains/dokka/gfm/templateProcessing/GfmTemplateProcessingStrategy.kt index 306412e3..8f23e8e9 100644 --- a/plugins/gfm/gfm-template-processing/src/main/kotlin/org/jetbrains/dokka/gfm/templateProcessing/GfmTemplateProcessingStrategy.kt +++ b/plugins/gfm/gfm-template-processing/src/main/kotlin/org/jetbrains/dokka/gfm/templateProcessing/GfmTemplateProcessingStrategy.kt @@ -20,7 +20,9 @@ import org.jetbrains.dokka.templates.TemplateProcessingStrategy import java.io.BufferedWriter import java.io.File -class GfmTemplateProcessingStrategy(val context: DokkaContext) : TemplateProcessingStrategy { +public class GfmTemplateProcessingStrategy( + public val context: DokkaContext +) : TemplateProcessingStrategy { private val externalModuleLinkResolver = context.plugin().querySingle { externalModuleLinkResolver } diff --git a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/GfmPlugin.kt b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/GfmPlugin.kt index 5ffa883a..3fd7b514 100644 --- a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/GfmPlugin.kt +++ b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/GfmPlugin.kt @@ -8,39 +8,39 @@ import org.jetbrains.dokka.CoreExtensions import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.renderers.PackageListCreator import org.jetbrains.dokka.base.renderers.RootCreator +import org.jetbrains.dokka.base.resolvers.local.LocationProviderFactory import org.jetbrains.dokka.base.resolvers.shared.RecognizedLinkFormat import org.jetbrains.dokka.gfm.location.MarkdownLocationProvider import org.jetbrains.dokka.gfm.renderer.BriefCommentPreprocessor import org.jetbrains.dokka.gfm.renderer.CommonmarkRenderer -import org.jetbrains.dokka.plugability.DokkaPlugin -import org.jetbrains.dokka.plugability.DokkaPluginApiPreview -import org.jetbrains.dokka.plugability.PluginApiPreviewAcknowledgement +import org.jetbrains.dokka.plugability.* import org.jetbrains.dokka.renderers.PostAction +import org.jetbrains.dokka.renderers.Renderer import org.jetbrains.dokka.transformers.pages.PageTransformer -class GfmPlugin : DokkaPlugin() { +public class GfmPlugin : DokkaPlugin() { - val gfmPreprocessors by extensionPoint() + public val gfmPreprocessors: ExtensionPoint by extensionPoint() private val dokkaBase by lazy { plugin() } - val renderer by extending { + public val renderer: Extension by extending { CoreExtensions.renderer providing ::CommonmarkRenderer override dokkaBase.htmlRenderer } - val locationProvider by extending { + public val locationProvider: Extension by extending { dokkaBase.locationProviderFactory providing MarkdownLocationProvider::Factory override dokkaBase.locationProvider } - val rootCreator by extending { + public val rootCreator: Extension by extending { gfmPreprocessors with RootCreator } - val briefCommentPreprocessor by extending { + public val briefCommentPreprocessor: Extension by extending { gfmPreprocessors with BriefCommentPreprocessor() } - val packageListCreator by extending { + public val packageListCreator: Extension by extending { (gfmPreprocessors providing { PackageListCreator(it, RecognizedLinkFormat.DokkaGFM) } order { after(rootCreator) }) diff --git a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/gfmTemplating.kt b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/gfmTemplating.kt index f30c5929..194127df 100644 --- a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/gfmTemplating.kt +++ b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/gfmTemplating.kt @@ -10,16 +10,21 @@ import org.jetbrains.dokka.base.templating.toJsonString import org.jetbrains.dokka.links.DRI @JsonTypeInfo(use = CLASS) -sealed class GfmCommand { - companion object { +public sealed class GfmCommand { + + public companion object { private const val delimiter = "\u1680" - val templateCommandRegex: Regex = + + public val templateCommandRegex: Regex = Regex("(.+?)(?=") - val MatchResult.command + + public val MatchResult.command: String get() = groupValues[1] - val MatchResult.label + + public val MatchResult.label: String get() = groupValues[2] - fun Appendable.templateCommand(command: GfmCommand, content: Appendable.() -> Unit) { + + public fun Appendable.templateCommand(command: GfmCommand, content: Appendable.() -> Unit) { append("") content() append("") @@ -27,6 +32,8 @@ sealed class GfmCommand { } } -class ResolveLinkGfmCommand(val dri: DRI) : GfmCommand() +public class ResolveLinkGfmCommand( + public val dri: DRI +) : GfmCommand() diff --git a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/location/MarkdownLocationProvider.kt b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/location/MarkdownLocationProvider.kt index 03025863..f331a6d9 100644 --- a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/location/MarkdownLocationProvider.kt +++ b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/location/MarkdownLocationProvider.kt @@ -5,17 +5,18 @@ package org.jetbrains.dokka.gfm.location import org.jetbrains.dokka.base.resolvers.local.DokkaLocationProvider +import org.jetbrains.dokka.base.resolvers.local.LocationProvider import org.jetbrains.dokka.base.resolvers.local.LocationProviderFactory import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaContext -class MarkdownLocationProvider( +public class MarkdownLocationProvider( pageGraphRoot: RootPageNode, dokkaContext: DokkaContext ) : DokkaLocationProvider(pageGraphRoot, dokkaContext, ".md") { - 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 = MarkdownLocationProvider(pageNode, context) } } diff --git a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/renderer/BriefCommentPreprocessor.kt b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/renderer/BriefCommentPreprocessor.kt index 56d75fd2..6023cca1 100644 --- a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/renderer/BriefCommentPreprocessor.kt +++ b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/renderer/BriefCommentPreprocessor.kt @@ -7,14 +7,16 @@ package org.jetbrains.dokka.gfm.renderer import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.transformers.pages.PageTransformer -class BriefCommentPreprocessor : PageTransformer { - override fun invoke(input: RootPageNode) = input.transformContentPagesTree { contentPage -> - contentPage.modified(content = contentPage.content.recursiveMapTransform { - if (it.dci.kind == ContentKind.BriefComment) { - it.copy(style = it.style + setOf(TextStyle.Block)) - } else { - it - } - }) +public class BriefCommentPreprocessor : PageTransformer { + override fun invoke(input: RootPageNode): RootPageNode { + return input.transformContentPagesTree { contentPage -> + contentPage.modified(content = contentPage.content.recursiveMapTransform { + if (it.dci.kind == ContentKind.BriefComment) { + it.copy(style = it.style + setOf(TextStyle.Block)) + } else { + it + } + }) + } } } diff --git a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/renderer/CommonmarkRenderer.kt b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/renderer/CommonmarkRenderer.kt index 3cfd17ef..3bc420ac 100644 --- a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/renderer/CommonmarkRenderer.kt +++ b/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/renderer/CommonmarkRenderer.kt @@ -15,13 +15,14 @@ import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.plugability.plugin import org.jetbrains.dokka.plugability.query +import org.jetbrains.dokka.transformers.pages.PageTransformer import org.jetbrains.dokka.utilities.htmlEscape -open class CommonmarkRenderer( +public open class CommonmarkRenderer( context: DokkaContext ) : DefaultRenderer(context) { - override val preprocessors = context.plugin().query { gfmPreprocessors } + override val preprocessors: List = context.plugin().query { gfmPreprocessors } private val isPartial = context.configuration.delayTemplateSubstitution -- cgit