aboutsummaryrefslogtreecommitdiff
path: root/plugins/gfm/gfm-template-processing
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2023-11-10 11:46:54 +0100
committerGitHub <noreply@github.com>2023-11-10 11:46:54 +0100
commit8e5c63d035ef44a269b8c43430f43f5c8eebfb63 (patch)
tree1b915207b2b9f61951ddbf0ff2e687efd053d555 /plugins/gfm/gfm-template-processing
parenta44efd4ba0c2e4ab921ff75e0f53fc9335aa79db (diff)
downloaddokka-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/gfm-template-processing')
-rw-r--r--plugins/gfm/gfm-template-processing/api/gfm-template-processing.api14
-rw-r--r--plugins/gfm/gfm-template-processing/build.gradle.kts29
-rw-r--r--plugins/gfm/gfm-template-processing/src/main/kotlin/org/jetbrains/dokka/gfm/templateProcessing/GfmTemplateProcessingPlugin.kt44
-rw-r--r--plugins/gfm/gfm-template-processing/src/main/kotlin/org/jetbrains/dokka/gfm/templateProcessing/GfmTemplateProcessingStrategy.kt72
-rw-r--r--plugins/gfm/gfm-template-processing/src/main/resources/META-INF/services/org.jetbrains.dokka.plugability.DokkaPlugin5
5 files changed, 0 insertions, 164 deletions
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