diff options
author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2023-08-31 20:16:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-31 20:16:01 +0200 |
commit | 02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33 (patch) | |
tree | 66f6d6f089a93b863bf1144666491eca6729ad05 /plugins/gfm | |
parent | 6a181a7a2b03ec263788d137610e86937a57d434 (diff) | |
download | dokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.tar.gz dokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.tar.bz2 dokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.zip |
Enable explicit API mode (#3139)
Diffstat (limited to 'plugins/gfm')
8 files changed, 53 insertions, 40 deletions
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 <init> (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<AllModulesPagePlugin>() } private val templateProcessingPlugin by lazy { plugin<TemplatingPlugin>() } - private val gfmPlugin by lazy { plugin<GfmPlugin>() } - private val dokkaBase by lazy { plugin<DokkaBase>()} - val gfmTemplateProcessingStrategy by extending { + public val gfmTemplateProcessingStrategy: Extension<TemplateProcessingStrategy, *, *> by extending { (templateProcessingPlugin.templateProcessingStrategy providing ::GfmTemplateProcessingStrategy order { before(templateProcessingPlugin.fallbackProcessingStrategy) }) } - val gfmLocationProvider by extending { + public val gfmLocationProvider: Extension<LocationProviderFactory, *, *> by extending { dokkaBase.locationProviderFactory providing MultimoduleLocationProvider::Factory override listOf(gfmPlugin.locationProvider, allModulesPagePlugin.multimoduleLocationProvider) } - val gfmPartialLocationProvider by extending { + public val gfmPartialLocationProvider: Extension<LocationProviderFactory, *, *> 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<AllModulesPagePlugin>().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<PageTransformer>() + public val gfmPreprocessors: ExtensionPoint<PageTransformer> by extensionPoint<PageTransformer>() private val dokkaBase by lazy { plugin<DokkaBase>() } - val renderer by extending { + public val renderer: Extension<Renderer, *, *> by extending { CoreExtensions.renderer providing ::CommonmarkRenderer override dokkaBase.htmlRenderer } - val locationProvider by extending { + public val locationProvider: Extension<LocationProviderFactory, *, *> by extending { dokkaBase.locationProviderFactory providing MarkdownLocationProvider::Factory override dokkaBase.locationProvider } - val rootCreator by extending { + public val rootCreator: Extension<PageTransformer, *, *> by extending { gfmPreprocessors with RootCreator } - val briefCommentPreprocessor by extending { + public val briefCommentPreprocessor: Extension<PageTransformer, *, *> by extending { gfmPreprocessors with BriefCommentPreprocessor() } - val packageListCreator by extending { + public val packageListCreator: Extension<PageTransformer, *, *> 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("<!---$delimiter GfmCommand ([^$delimiter ]*)$delimiter--->(.+?)(?=<!---$delimiter)<!---$delimiter--->") - 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("<!---$delimiter GfmCommand ${toJsonString(command)}$delimiter--->") content() append("<!---$delimiter--->") @@ -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<ContentGroup, ContentNode> { - 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<ContentGroup, ContentNode> { + 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<StringBuilder>(context) { - override val preprocessors = context.plugin<GfmPlugin>().query { gfmPreprocessors } + override val preprocessors: List<PageTransformer> = context.plugin<GfmPlugin>().query { gfmPreprocessors } private val isPartial = context.configuration.delayTemplateSubstitution |