diff options
| author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2023-11-10 11:46:54 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-10 11:46:54 +0100 |
| commit | 8e5c63d035ef44a269b8c43430f43f5c8eebfb63 (patch) | |
| tree | 1b915207b2b9f61951ddbf0ff2e687efd053d555 /plugins/gfm | |
| parent | a44efd4ba0c2e4ab921ff75e0f53fc9335aa79db (diff) | |
| download | dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.tar.gz dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.tar.bz2 dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.zip | |
Restructure the project to utilize included builds (#3174)
* Refactor and simplify artifact publishing
* Update Gradle to 8.4
* Refactor and simplify convention plugins and build scripts
Fixes #3132
---------
Co-authored-by: Adam <897017+aSemy@users.noreply.github.com>
Co-authored-by: Oleg Yukhnevich <whyoleg@gmail.com>
Diffstat (limited to 'plugins/gfm')
20 files changed, 0 insertions, 2154 deletions
diff --git a/plugins/gfm/README.md b/plugins/gfm/README.md deleted file mode 100644 index 1d65c0f0..00000000 --- a/plugins/gfm/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# GFM plugin - -The GFM plugin adds the ability to generate documentation in `GitHub Flavoured Markdown` format. It supports both -multi-module and multiplatform projects. - -The GFM plugin is shipped together with the Dokka Gradle Plugin, so you can start using it -right away with one of the following tasks: - -* `dokkaGfm` - generate documentation for a single-project build or one specific module. -* `dokkaGfmMultiModule` - generate documentation for a multi-module project, assemble it together and - generate navigation page/menu for all the modules. - -To use it with Maven or the CLI runner, you have to add it as a dependency. You can find it on -[Maven Central](https://mvnrepository.com/artifact/org.jetbrains.dokka/gfm-plugin) - -GFM plugin comes built in with the Dokka Gradle plugin. You can also find it on -[Maven Central](https://mvnrepository.com/artifact/org.jetbrains.dokka/gfm-plugin). diff --git a/plugins/gfm/api/gfm.api b/plugins/gfm/api/gfm.api deleted file mode 100644 index f77c9b68..00000000 --- a/plugins/gfm/api/gfm.api +++ /dev/null @@ -1,77 +0,0 @@ -public abstract class org/jetbrains/dokka/gfm/GfmCommand { - public static final field Companion Lorg/jetbrains/dokka/gfm/GfmCommand$Companion; -} - -public final class org/jetbrains/dokka/gfm/GfmCommand$Companion { - public final fun getCommand (Lkotlin/text/MatchResult;)Ljava/lang/String; - public final fun getLabel (Lkotlin/text/MatchResult;)Ljava/lang/String; - public final fun getTemplateCommandRegex ()Lkotlin/text/Regex; - public final fun templateCommand (Ljava/lang/Appendable;Lorg/jetbrains/dokka/gfm/GfmCommand;Lkotlin/jvm/functions/Function1;)V -} - -public final class org/jetbrains/dokka/gfm/GfmPlugin : org/jetbrains/dokka/plugability/DokkaPlugin { - public fun <init> ()V - public final fun getBriefCommentPreprocessor ()Lorg/jetbrains/dokka/plugability/Extension; - public final fun getGfmPreprocessors ()Lorg/jetbrains/dokka/plugability/ExtensionPoint; - public final fun getLocationProvider ()Lorg/jetbrains/dokka/plugability/Extension; - public final fun getPackageListCreator ()Lorg/jetbrains/dokka/plugability/Extension; - public final fun getRenderer ()Lorg/jetbrains/dokka/plugability/Extension; - public final fun getRootCreator ()Lorg/jetbrains/dokka/plugability/Extension; -} - -public final class org/jetbrains/dokka/gfm/ResolveLinkGfmCommand : org/jetbrains/dokka/gfm/GfmCommand { - public fun <init> (Lorg/jetbrains/dokka/links/DRI;)V - public final fun getDri ()Lorg/jetbrains/dokka/links/DRI; -} - -public final class org/jetbrains/dokka/gfm/location/MarkdownLocationProvider : org/jetbrains/dokka/base/resolvers/local/DokkaLocationProvider { - public fun <init> (Lorg/jetbrains/dokka/pages/RootPageNode;Lorg/jetbrains/dokka/plugability/DokkaContext;)V -} - -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 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 { - public fun <init> ()V - public fun invoke (Lorg/jetbrains/dokka/pages/RootPageNode;)Lorg/jetbrains/dokka/pages/RootPageNode; -} - -public class org/jetbrains/dokka/gfm/renderer/CommonmarkRenderer : org/jetbrains/dokka/base/renderers/DefaultRenderer { - public fun <init> (Lorg/jetbrains/dokka/plugability/DokkaContext;)V - public synthetic fun buildCodeBlock (Ljava/lang/Object;Lorg/jetbrains/dokka/pages/ContentCodeBlock;Lorg/jetbrains/dokka/pages/ContentPage;)V - public fun buildCodeBlock (Ljava/lang/StringBuilder;Lorg/jetbrains/dokka/pages/ContentCodeBlock;Lorg/jetbrains/dokka/pages/ContentPage;)V - public synthetic fun buildCodeInline (Ljava/lang/Object;Lorg/jetbrains/dokka/pages/ContentCodeInline;Lorg/jetbrains/dokka/pages/ContentPage;)V - public fun buildCodeInline (Ljava/lang/StringBuilder;Lorg/jetbrains/dokka/pages/ContentCodeInline;Lorg/jetbrains/dokka/pages/ContentPage;)V - public synthetic fun buildDRILink (Ljava/lang/Object;Lorg/jetbrains/dokka/pages/ContentDRILink;Lorg/jetbrains/dokka/pages/ContentPage;Ljava/util/Set;)V - public fun buildDRILink (Ljava/lang/StringBuilder;Lorg/jetbrains/dokka/pages/ContentDRILink;Lorg/jetbrains/dokka/pages/ContentPage;Ljava/util/Set;)V - public synthetic fun buildDivergent (Ljava/lang/Object;Lorg/jetbrains/dokka/pages/ContentDivergentGroup;Lorg/jetbrains/dokka/pages/ContentPage;)V - public fun buildDivergent (Ljava/lang/StringBuilder;Lorg/jetbrains/dokka/pages/ContentDivergentGroup;Lorg/jetbrains/dokka/pages/ContentPage;)V - public fun buildError (Lorg/jetbrains/dokka/pages/ContentNode;)V - public synthetic fun buildHeader (Ljava/lang/Object;ILorg/jetbrains/dokka/pages/ContentHeader;Lkotlin/jvm/functions/Function1;)V - public fun buildHeader (Ljava/lang/StringBuilder;ILorg/jetbrains/dokka/pages/ContentHeader;Lkotlin/jvm/functions/Function1;)V - public synthetic fun buildLineBreak (Ljava/lang/Object;)V - public fun buildLineBreak (Ljava/lang/StringBuilder;)V - public synthetic fun buildLink (Ljava/lang/Object;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V - public fun buildLink (Ljava/lang/StringBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V - public synthetic fun buildList (Ljava/lang/Object;Lorg/jetbrains/dokka/pages/ContentList;Lorg/jetbrains/dokka/pages/ContentPage;Ljava/util/Set;)V - public fun buildList (Ljava/lang/StringBuilder;Lorg/jetbrains/dokka/pages/ContentList;Lorg/jetbrains/dokka/pages/ContentPage;Ljava/util/Set;)V - public synthetic fun buildNavigation (Ljava/lang/Object;Lorg/jetbrains/dokka/pages/PageNode;)V - public fun buildNavigation (Ljava/lang/StringBuilder;Lorg/jetbrains/dokka/pages/PageNode;)V - public fun buildPage (Lorg/jetbrains/dokka/pages/ContentPage;Lkotlin/jvm/functions/Function2;)Ljava/lang/String; - public synthetic fun buildPlatformDependent (Ljava/lang/Object;Lorg/jetbrains/dokka/pages/PlatformHintedContent;Lorg/jetbrains/dokka/pages/ContentPage;Ljava/util/Set;)V - public fun buildPlatformDependent (Ljava/lang/StringBuilder;Lorg/jetbrains/dokka/pages/PlatformHintedContent;Lorg/jetbrains/dokka/pages/ContentPage;Ljava/util/Set;)V - public synthetic fun buildResource (Ljava/lang/Object;Lorg/jetbrains/dokka/pages/ContentEmbeddedResource;Lorg/jetbrains/dokka/pages/ContentPage;)V - public fun buildResource (Ljava/lang/StringBuilder;Lorg/jetbrains/dokka/pages/ContentEmbeddedResource;Lorg/jetbrains/dokka/pages/ContentPage;)V - public synthetic fun buildTable (Ljava/lang/Object;Lorg/jetbrains/dokka/pages/ContentTable;Lorg/jetbrains/dokka/pages/ContentPage;Ljava/util/Set;)V - public fun buildTable (Ljava/lang/StringBuilder;Lorg/jetbrains/dokka/pages/ContentTable;Lorg/jetbrains/dokka/pages/ContentPage;Ljava/util/Set;)V - public synthetic fun buildText (Ljava/lang/Object;Lorg/jetbrains/dokka/pages/ContentText;)V - public fun buildText (Ljava/lang/StringBuilder;Lorg/jetbrains/dokka/pages/ContentText;)V - public synthetic fun getPreprocessors ()Ljava/lang/Iterable; - protected fun getPreprocessors ()Ljava/util/List; - public fun renderPage (Lorg/jetbrains/dokka/pages/PageNode;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public synthetic fun wrapGroup (Ljava/lang/Object;Lorg/jetbrains/dokka/pages/ContentGroup;Lorg/jetbrains/dokka/pages/ContentPage;Lkotlin/jvm/functions/Function1;)V - public fun wrapGroup (Ljava/lang/StringBuilder;Lorg/jetbrains/dokka/pages/ContentGroup;Lorg/jetbrains/dokka/pages/ContentPage;Lkotlin/jvm/functions/Function1;)V -} - diff --git a/plugins/gfm/build.gradle.kts b/plugins/gfm/build.gradle.kts deleted file mode 100644 index bc83f742..00000000 --- a/plugins/gfm/build.gradle.kts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -import org.jetbrains.registerDokkaArtifactPublication - -plugins { - id("org.jetbrains.conventions.kotlin-jvm") - id("org.jetbrains.conventions.maven-publish") -} - -dependencies { - compileOnly(projects.core) - - implementation(projects.plugins.base) - - implementation(kotlin("reflect")) - implementation(libs.jackson.kotlin) - constraints { - implementation(libs.jackson.databind) { - because("CVE-2022-42003") - } - } - - testImplementation(kotlin("test")) - testImplementation(projects.plugins.base) - testImplementation(projects.plugins.base.baseTestUtils) - testImplementation(projects.core.testApi) -} - -registerDokkaArtifactPublication("gfmPlugin") { - artifactId = "gfm-plugin" -} diff --git a/plugins/gfm/gfm-template-processing/api/gfm-template-processing.api b/plugins/gfm/gfm-template-processing/api/gfm-template-processing.api deleted file mode 100644 index e94d666e..00000000 --- a/plugins/gfm/gfm-template-processing/api/gfm-template-processing.api +++ /dev/null @@ -1,14 +0,0 @@ -public final class org/jetbrains/dokka/gfm/templateProcessing/GfmTemplateProcessingPlugin : org/jetbrains/dokka/plugability/DokkaPlugin { - public fun <init> ()V - public final fun getGfmLocationProvider ()Lorg/jetbrains/dokka/plugability/Extension; - public final fun getGfmPartialLocationProvider ()Lorg/jetbrains/dokka/plugability/Extension; - public final fun getGfmTemplateProcessingStrategy ()Lorg/jetbrains/dokka/plugability/Extension; -} - -public final class org/jetbrains/dokka/gfm/templateProcessing/GfmTemplateProcessingStrategy : org/jetbrains/dokka/templates/TemplateProcessingStrategy { - public fun <init> (Lorg/jetbrains/dokka/plugability/DokkaContext;)V - public fun finish (Ljava/io/File;)V - public final fun getContext ()Lorg/jetbrains/dokka/plugability/DokkaContext; - public fun process (Ljava/io/File;Ljava/io/File;Lorg/jetbrains/dokka/DokkaConfiguration$DokkaModuleDescription;)Z -} - diff --git a/plugins/gfm/gfm-template-processing/build.gradle.kts b/plugins/gfm/gfm-template-processing/build.gradle.kts deleted file mode 100644 index 955e052f..00000000 --- a/plugins/gfm/gfm-template-processing/build.gradle.kts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -import org.jetbrains.registerDokkaArtifactPublication - -plugins { - id("org.jetbrains.conventions.kotlin-jvm") - id("org.jetbrains.conventions.maven-publish") -} - -dependencies { - compileOnly(projects.core) - - implementation(projects.plugins.base) - implementation(projects.plugins.gfm) - implementation(projects.plugins.allModulesPage) - implementation(projects.plugins.templating) - - implementation(kotlin("reflect")) - implementation(libs.kotlinx.coroutines.core) - - testImplementation(kotlin("test")) - testImplementation(projects.core.testApi) -} - -registerDokkaArtifactPublication("dokkaGfmTemplateProcessing") { - artifactId = "gfm-template-processing-plugin" -} 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 deleted file mode 100644 index fd2af274..00000000 --- a/plugins/gfm/gfm-template-processing/src/main/kotlin/org/jetbrains/dokka/gfm/templateProcessing/GfmTemplateProcessingPlugin.kt +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -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 - -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>()} - - public val gfmTemplateProcessingStrategy: Extension<TemplateProcessingStrategy, *, *> by extending { - (templateProcessingPlugin.templateProcessingStrategy - providing ::GfmTemplateProcessingStrategy - order { before(templateProcessingPlugin.fallbackProcessingStrategy) }) - } - - public val gfmLocationProvider: Extension<LocationProviderFactory, *, *> by extending { - dokkaBase.locationProviderFactory providing MultimoduleLocationProvider::Factory override listOf(gfmPlugin.locationProvider, allModulesPagePlugin.multimoduleLocationProvider) - } - - public val gfmPartialLocationProvider: Extension<LocationProviderFactory, *, *> by extending { - allModulesPagePlugin.partialLocationProviderFactory providing MarkdownLocationProvider::Factory override allModulesPagePlugin.baseLocationProviderFactory - } - - @OptIn(DokkaPluginApiPreview::class) - override fun pluginApiPreviewAcknowledgement(): PluginApiPreviewAcknowledgement = - PluginApiPreviewAcknowledgement -} 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 deleted file mode 100644 index 8f23e8e9..00000000 --- a/plugins/gfm/gfm-template-processing/src/main/kotlin/org/jetbrains/dokka/gfm/templateProcessing/GfmTemplateProcessingStrategy.kt +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.gfm.templateProcessing - -import org.jetbrains.dokka.DokkaConfiguration -import org.jetbrains.dokka.allModulesPage.AllModulesPagePlugin -import org.jetbrains.dokka.base.templating.parseJson -import org.jetbrains.dokka.gfm.GfmCommand -import org.jetbrains.dokka.gfm.GfmCommand.Companion.command -import org.jetbrains.dokka.gfm.GfmCommand.Companion.label -import org.jetbrains.dokka.gfm.GfmCommand.Companion.templateCommandRegex -import org.jetbrains.dokka.gfm.ResolveLinkGfmCommand -import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.plugability.DokkaContext -import org.jetbrains.dokka.plugability.plugin -import org.jetbrains.dokka.plugability.querySingle -import org.jetbrains.dokka.templates.TemplateProcessingStrategy -import java.io.BufferedWriter -import java.io.File - -public class GfmTemplateProcessingStrategy( - public val context: DokkaContext -) : TemplateProcessingStrategy { - - private val externalModuleLinkResolver = - context.plugin<AllModulesPagePlugin>().querySingle { externalModuleLinkResolver } - - override fun process(input: File, output: File, moduleContext: DokkaConfiguration.DokkaModuleDescription?): Boolean = - if (input.extension == "md") { - input.bufferedReader().use { reader -> - //This should also work whenever we have a misconfigured dokka and output is pointing to the input - //the same way that html processing does - if (input.absolutePath == output.absolutePath) { - context.logger.info("Attempting to process GFM templates in place for directory $input, this suggests miss configuration.") - val lines = reader.readLines() - output.bufferedWriter().use { writer -> - lines.forEach { line -> - writer.processAndWrite(line, output) - } - - } - } else { - output.bufferedWriter().use { writer -> - reader.lineSequence().forEach { line -> - writer.processAndWrite(line, output) - } - } - } - } - true - } else false - - private fun BufferedWriter.processAndWrite(line: String, output: File) = - processLine(line, output).run { - write(this) - newLine() - } - - private fun processLine(line: String, output: File): String = - line.replace(templateCommandRegex) { - when (val command = parseJson<GfmCommand>(it.command)) { - is ResolveLinkGfmCommand -> resolveLink(output, command.dri, it.label) - } - } - - private fun resolveLink(fileContext: File, dri: DRI, label: String): String = - externalModuleLinkResolver.resolve(dri, fileContext)?.let { address -> - "[$label]($address)" - } ?: label -} diff --git a/plugins/gfm/gfm-template-processing/src/main/resources/META-INF/services/org.jetbrains.dokka.plugability.DokkaPlugin b/plugins/gfm/gfm-template-processing/src/main/resources/META-INF/services/org.jetbrains.dokka.plugability.DokkaPlugin deleted file mode 100644 index 375990bb..00000000 --- a/plugins/gfm/gfm-template-processing/src/main/resources/META-INF/services/org.jetbrains.dokka.plugability.DokkaPlugin +++ /dev/null @@ -1,5 +0,0 @@ -# -# Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. -# - -org.jetbrains.dokka.gfm.templateProcessing.GfmTemplateProcessingPlugin 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 deleted file mode 100644 index 3fd7b514..00000000 --- a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/GfmPlugin.kt +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.gfm - -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.* -import org.jetbrains.dokka.renderers.PostAction -import org.jetbrains.dokka.renderers.Renderer -import org.jetbrains.dokka.transformers.pages.PageTransformer - -public class GfmPlugin : DokkaPlugin() { - - public val gfmPreprocessors: ExtensionPoint<PageTransformer> by extensionPoint<PageTransformer>() - - private val dokkaBase by lazy { plugin<DokkaBase>() } - - public val renderer: Extension<Renderer, *, *> by extending { - CoreExtensions.renderer providing ::CommonmarkRenderer override dokkaBase.htmlRenderer - } - - public val locationProvider: Extension<LocationProviderFactory, *, *> by extending { - dokkaBase.locationProviderFactory providing MarkdownLocationProvider::Factory override dokkaBase.locationProvider - } - - public val rootCreator: Extension<PageTransformer, *, *> by extending { - gfmPreprocessors with RootCreator - } - - public val briefCommentPreprocessor: Extension<PageTransformer, *, *> by extending { - gfmPreprocessors with BriefCommentPreprocessor() - } - - public val packageListCreator: Extension<PageTransformer, *, *> by extending { - (gfmPreprocessors - providing { PackageListCreator(it, RecognizedLinkFormat.DokkaGFM) } - order { after(rootCreator) }) - } - - internal val alphaVersionNotifier by extending { - CoreExtensions.postActions providing { ctx -> - PostAction { - ctx.logger.info( - "The GFM output format is still in Alpha so you may find bugs and experience migration " + - "issues when using it. You use it at your own risk." - ) - } - } - } - - @OptIn(DokkaPluginApiPreview::class) - override fun pluginApiPreviewAcknowledgement(): PluginApiPreviewAcknowledgement = - PluginApiPreviewAcknowledgement -} 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 deleted file mode 100644 index 194127df..00000000 --- a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/gfmTemplating.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.gfm - -import com.fasterxml.jackson.annotation.JsonTypeInfo -import com.fasterxml.jackson.annotation.JsonTypeInfo.Id.CLASS -import org.jetbrains.dokka.base.templating.toJsonString -import org.jetbrains.dokka.links.DRI - -@JsonTypeInfo(use = CLASS) -public sealed class GfmCommand { - - public companion object { - private const val delimiter = "\u1680" - - public val templateCommandRegex: Regex = - Regex("<!---$delimiter GfmCommand ([^$delimiter ]*)$delimiter--->(.+?)(?=<!---$delimiter)<!---$delimiter--->") - - public val MatchResult.command: String - get() = groupValues[1] - - public val MatchResult.label: String - get() = groupValues[2] - - public fun Appendable.templateCommand(command: GfmCommand, content: Appendable.() -> Unit) { - append("<!---$delimiter GfmCommand ${toJsonString(command)}$delimiter--->") - content() - append("<!---$delimiter--->") - } - } -} - -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 deleted file mode 100644 index f331a6d9..00000000 --- a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/location/MarkdownLocationProvider.kt +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -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 - -public class MarkdownLocationProvider( - pageGraphRoot: RootPageNode, - dokkaContext: DokkaContext -) : DokkaLocationProvider(pageGraphRoot, dokkaContext, ".md") { - - 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 deleted file mode 100644 index 6023cca1..00000000 --- a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/renderer/BriefCommentPreprocessor.kt +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.gfm.renderer - -import org.jetbrains.dokka.pages.* -import org.jetbrains.dokka.transformers.pages.PageTransformer - -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 deleted file mode 100644 index 3bc420ac..00000000 --- a/plugins/gfm/src/main/kotlin/org/jetbrains/dokka/gfm/renderer/CommonmarkRenderer.kt +++ /dev/null @@ -1,414 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.gfm.renderer - -import org.jetbrains.dokka.DokkaException -import org.jetbrains.dokka.base.renderers.DefaultRenderer -import org.jetbrains.dokka.base.renderers.isImage -import org.jetbrains.dokka.gfm.GfmCommand.Companion.templateCommand -import org.jetbrains.dokka.gfm.GfmPlugin -import org.jetbrains.dokka.gfm.ResolveLinkGfmCommand -import org.jetbrains.dokka.model.DisplaySourceSet -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 - -public open class CommonmarkRenderer( - context: DokkaContext -) : DefaultRenderer<StringBuilder>(context) { - - override val preprocessors: List<PageTransformer> = context.plugin<GfmPlugin>().query { gfmPreprocessors } - - private val isPartial = context.configuration.delayTemplateSubstitution - - override fun StringBuilder.wrapGroup( - node: ContentGroup, - pageContext: ContentPage, - childrenCallback: StringBuilder.() -> Unit - ) { - return when { - node.hasStyle(TextStyle.Block) || node.hasStyle(TextStyle.Paragraph) -> { - buildParagraph() - childrenCallback() - buildParagraph() - } - node.dci.kind == ContentKind.Deprecation -> { - append("---") - childrenCallback() - append("---") - buildNewLine() - } - node.hasStyle(ContentStyle.Footnote) -> { - childrenCallback() - buildParagraph() - } - else -> childrenCallback() - } - } - - override fun StringBuilder.buildHeader(level: Int, node: ContentHeader, content: StringBuilder.() -> Unit) { - buildParagraph() - append("#".repeat(level) + " ") - content() - buildParagraph() - } - - override fun StringBuilder.buildLink(address: String, content: StringBuilder.() -> Unit) { - append("[") - content() - append("]($address)") - } - - override fun StringBuilder.buildList( - node: ContentList, - pageContext: ContentPage, - sourceSetRestriction: Set<DisplaySourceSet>? - ) { - buildParagraph() - buildList(node, pageContext) - buildParagraph() - } - - private fun StringBuilder.buildList( - node: ContentList, - pageContext: ContentPage - ) { - node.children.forEachIndexed { i, it -> - if (node.ordered) { - // number is irrelevant, but a nice touch - // period is more widely compatible - append("${i + 1}. ") - } else { - append("- ") - } - - /* - Handle case when list item transitions to another complex node with no preceding text. - For example, the equivalent of: - <li> - <ul><li><ul>Item</ul></li></ul> - </li> - - Would be: - - - - Item - */ - if (it is ContentGroup && it.children.firstOrNull()?.let { it !is ContentText } == true) { - append("\n ") - } - - buildString { it.build(this, pageContext, it.sourceSets) } - .replace("\n", "\n ") // apply indent - .trim().let { append(it) } - buildNewLine() - } - } - - override fun StringBuilder.buildDRILink( - node: ContentDRILink, - pageContext: ContentPage, - sourceSetRestriction: Set<DisplaySourceSet>? - ) { - val location = locationProvider.resolve(node.address, node.sourceSets, pageContext) - if (location == null) { - if (isPartial) { - templateCommand(ResolveLinkGfmCommand(node.address)) { - buildText(node.children, pageContext, sourceSetRestriction) - } - } else { - buildText(node.children, pageContext, sourceSetRestriction) - } - } else { - buildLink(location) { - buildText(node.children, pageContext, sourceSetRestriction) - } - } - } - - override fun StringBuilder.buildLineBreak() { - append("\\") - buildNewLine() - } - - private fun StringBuilder.buildNewLine() { - append("\n") - } - - private fun StringBuilder.buildParagraph() { - buildNewLine() - buildNewLine() - } - - override fun StringBuilder.buildPlatformDependent( - content: PlatformHintedContent, - pageContext: ContentPage, - sourceSetRestriction: Set<DisplaySourceSet>? - ) { - buildPlatformDependentItem(content.inner, content.sourceSets, pageContext) - } - - private fun StringBuilder.buildPlatformDependentItem( - content: ContentNode, - sourceSets: Set<DisplaySourceSet>, - pageContext: ContentPage, - ) { - if (content is ContentGroup && content.children.firstOrNull { it is ContentTable } != null) { - buildContentNode(content, pageContext, sourceSets) - } else { - val distinct = sourceSets.map { - it to buildString { buildContentNode(content, pageContext, setOf(it)) } - }.groupBy(Pair<DisplaySourceSet, String>::second, Pair<DisplaySourceSet, String>::first) - - distinct.filter { it.key.isNotBlank() }.forEach { (text, platforms) -> - buildParagraph() - buildSourceSetTags(platforms.toSet()) - buildLineBreak() - append(text.trim()) - buildParagraph() - } - } - } - - override fun StringBuilder.buildResource(node: ContentEmbeddedResource, pageContext: ContentPage) { - if (node.isImage()) { - append("!") - } - append("[${node.altText}](${node.address})") - } - - override fun StringBu |
