aboutsummaryrefslogtreecommitdiff
path: root/plugins/gfm/gfm-template-processing/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/gfm/gfm-template-processing/src/main')
-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
3 files changed, 0 insertions, 121 deletions
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