aboutsummaryrefslogtreecommitdiff
path: root/plugins/templating/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/templating/src/main')
-rw-r--r--plugins/templating/src/main/kotlin/templates/AddToNavigationCommandHandler.kt6
-rw-r--r--plugins/templating/src/main/kotlin/templates/CommandHandler.kt14
-rw-r--r--plugins/templating/src/main/kotlin/templates/DirectiveBasedTemplateProcessing.kt6
-rw-r--r--plugins/templating/src/main/kotlin/templates/FallbackTemplateProcessingStrategy.kt2
-rw-r--r--plugins/templating/src/main/kotlin/templates/JsonElementBasedTemplateProcessingStrategy.kt15
-rw-r--r--plugins/templating/src/main/kotlin/templates/PackageListProcessingStrategy.kt4
-rw-r--r--plugins/templating/src/main/kotlin/templates/PathToRootSubstitutor.kt4
-rw-r--r--plugins/templating/src/main/kotlin/templates/ProjectNameSubstitutor.kt4
-rw-r--r--plugins/templating/src/main/kotlin/templates/ReplaceVersionCommandHandler.kt4
-rw-r--r--plugins/templating/src/main/kotlin/templates/SourcesetDependencyProcessingStrategy.kt4
-rw-r--r--plugins/templating/src/main/kotlin/templates/SubstitutionCommandHandler.kt2
-rw-r--r--plugins/templating/src/main/kotlin/templates/Substitutor.kt4
-rw-r--r--plugins/templating/src/main/kotlin/templates/TemplateProcessor.kt35
-rw-r--r--plugins/templating/src/main/kotlin/templates/TemplatingPlugin.kt41
14 files changed, 81 insertions, 64 deletions
diff --git a/plugins/templating/src/main/kotlin/templates/AddToNavigationCommandHandler.kt b/plugins/templating/src/main/kotlin/templates/AddToNavigationCommandHandler.kt
index de4e3637..78c6c684 100644
--- a/plugins/templating/src/main/kotlin/templates/AddToNavigationCommandHandler.kt
+++ b/plugins/templating/src/main/kotlin/templates/AddToNavigationCommandHandler.kt
@@ -14,7 +14,9 @@ import java.io.File
import java.nio.file.Files
import java.util.concurrent.ConcurrentHashMap
-class AddToNavigationCommandHandler(val context: DokkaContext) : CommandHandler {
+public class AddToNavigationCommandHandler(
+ public val context: DokkaContext
+) : CommandHandler {
private val navigationFragments = ConcurrentHashMap<String, Element>()
override fun handleCommandAsTag(command: Command, body: Element, input: File, output: File) {
@@ -25,7 +27,7 @@ class AddToNavigationCommandHandler(val context: DokkaContext) : CommandHandler
?.let { key -> navigationFragments[key.toString()] = body }
}
- override fun canHandle(command: Command) = command is AddToNavigationCommand
+ override fun canHandle(command: Command): Boolean = command is AddToNavigationCommand
override fun finish(output: File) {
if (navigationFragments.isNotEmpty()) {
diff --git a/plugins/templating/src/main/kotlin/templates/CommandHandler.kt b/plugins/templating/src/main/kotlin/templates/CommandHandler.kt
index 1aeda1ca..c06d52c3 100644
--- a/plugins/templating/src/main/kotlin/templates/CommandHandler.kt
+++ b/plugins/templating/src/main/kotlin/templates/CommandHandler.kt
@@ -10,14 +10,16 @@ import org.jsoup.nodes.Node
import java.io.File
-interface CommandHandler {
+public interface CommandHandler {
@Deprecated("This was renamed to handleCommandAsTag", ReplaceWith("handleCommandAsTag(command, element, input, output)"))
- fun handleCommand(element: Element, command: Command, input: File, output: File) { }
+ public fun handleCommand(element: Element, command: Command, input: File, output: File) { }
@Suppress("DEPRECATION")
- fun handleCommandAsTag(command: Command, body: Element, input: File, output: File) =
+ public fun handleCommandAsTag(command: Command, body: Element, input: File, output: File) {
handleCommand(body, command, input, output)
- fun handleCommandAsComment(command: Command, body: List<Node>, input: File, output: File) { }
- fun canHandle(command: Command): Boolean
- fun finish(output: File) {}
+ }
+ public fun handleCommandAsComment(command: Command, body: List<Node>, input: File, output: File) { }
+ public fun canHandle(command: Command): Boolean
+ public fun finish(output: File) {}
}
+
diff --git a/plugins/templating/src/main/kotlin/templates/DirectiveBasedTemplateProcessing.kt b/plugins/templating/src/main/kotlin/templates/DirectiveBasedTemplateProcessing.kt
index 5828884b..c36f2834 100644
--- a/plugins/templating/src/main/kotlin/templates/DirectiveBasedTemplateProcessing.kt
+++ b/plugins/templating/src/main/kotlin/templates/DirectiveBasedTemplateProcessing.kt
@@ -21,7 +21,7 @@ import org.jsoup.nodes.TextNode
import java.io.File
import java.nio.file.Files
-class DirectiveBasedHtmlTemplateProcessingStrategy(private val context: DokkaContext) : TemplateProcessingStrategy {
+public class DirectiveBasedHtmlTemplateProcessingStrategy(private val context: DokkaContext) : TemplateProcessingStrategy {
private val directiveBasedCommandHandlers =
context.plugin<TemplatingPlugin>().query { directiveBasedCommandHandlers }
@@ -45,11 +45,11 @@ class DirectiveBasedHtmlTemplateProcessingStrategy(private val context: DokkaCon
true
} else false
- fun handleCommandAsTag(element: Element, command: Command, input: File, output: File) {
+ public fun handleCommandAsTag(element: Element, command: Command, input: File, output: File) {
traverseHandlers(command) { handleCommandAsTag(command, element, input, output) }
}
- fun handleCommandAsComment(command: Command, body: List<Node>, input: File, output: File) {
+ public fun handleCommandAsComment(command: Command, body: List<Node>, input: File, output: File) {
traverseHandlers(command) { handleCommandAsComment(command, body, input, output) }
}
diff --git a/plugins/templating/src/main/kotlin/templates/FallbackTemplateProcessingStrategy.kt b/plugins/templating/src/main/kotlin/templates/FallbackTemplateProcessingStrategy.kt
index 60333445..a76d8eae 100644
--- a/plugins/templating/src/main/kotlin/templates/FallbackTemplateProcessingStrategy.kt
+++ b/plugins/templating/src/main/kotlin/templates/FallbackTemplateProcessingStrategy.kt
@@ -7,7 +7,7 @@ package org.jetbrains.dokka.templates
import org.jetbrains.dokka.DokkaConfiguration
import java.io.File
-class FallbackTemplateProcessingStrategy : TemplateProcessingStrategy {
+public class FallbackTemplateProcessingStrategy : TemplateProcessingStrategy {
override fun process(input: File, output: File, moduleContext: DokkaConfiguration.DokkaModuleDescription?): Boolean {
if (input != output) input.copyTo(output, overwrite = true)
diff --git a/plugins/templating/src/main/kotlin/templates/JsonElementBasedTemplateProcessingStrategy.kt b/plugins/templating/src/main/kotlin/templates/JsonElementBasedTemplateProcessingStrategy.kt
index 59432f0b..8c6cee03 100644
--- a/plugins/templating/src/main/kotlin/templates/JsonElementBasedTemplateProcessingStrategy.kt
+++ b/plugins/templating/src/main/kotlin/templates/JsonElementBasedTemplateProcessingStrategy.kt
@@ -14,13 +14,15 @@ import org.jetbrains.dokka.templates.TemplateProcessingStrategy
import java.io.File
import java.util.concurrent.ConcurrentHashMap
-abstract class BaseJsonNavigationTemplateProcessingStrategy(val context: DokkaContext) : TemplateProcessingStrategy {
- abstract val navigationFileNameWithoutExtension: String
- abstract val path: String
+public abstract class BaseJsonNavigationTemplateProcessingStrategy(
+ public val context: DokkaContext
+) : TemplateProcessingStrategy {
+ public abstract val navigationFileNameWithoutExtension: String
+ public abstract val path: String
private val fragments = ConcurrentHashMap<String, List<SearchRecord>>()
- open fun canProcess(file: File): Boolean =
+ public open fun canProcess(file: File): Boolean =
file.extension == "json" && file.nameWithoutExtension == navigationFileNameWithoutExtension
override fun process(input: File, output: File, moduleContext: DokkaModuleDescription?): Boolean {
@@ -57,8 +59,9 @@ abstract class BaseJsonNavigationTemplateProcessingStrategy(val context: DokkaCo
}
-class PagesSearchTemplateStrategy(val dokkaContext: DokkaContext) :
- BaseJsonNavigationTemplateProcessingStrategy(dokkaContext) {
+public class PagesSearchTemplateStrategy(
+ public val dokkaContext: DokkaContext
+) : BaseJsonNavigationTemplateProcessingStrategy(dokkaContext) {
override val navigationFileNameWithoutExtension: String = "pages"
override val path: String = "scripts"
}
diff --git a/plugins/templating/src/main/kotlin/templates/PackageListProcessingStrategy.kt b/plugins/templating/src/main/kotlin/templates/PackageListProcessingStrategy.kt
index bbee8280..4da45e3f 100644
--- a/plugins/templating/src/main/kotlin/templates/PackageListProcessingStrategy.kt
+++ b/plugins/templating/src/main/kotlin/templates/PackageListProcessingStrategy.kt
@@ -12,7 +12,9 @@ import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.templates.TemplateProcessingStrategy
import java.io.File
-class PackageListProcessingStrategy(val context: DokkaContext) : TemplateProcessingStrategy {
+public class PackageListProcessingStrategy(
+ public val context: DokkaContext
+) : TemplateProcessingStrategy {
private val fragments = mutableSetOf<PackageList>()
private fun canProcess(file: File, moduleContext: DokkaModuleDescription?): Boolean =
diff --git a/plugins/templating/src/main/kotlin/templates/PathToRootSubstitutor.kt b/plugins/templating/src/main/kotlin/templates/PathToRootSubstitutor.kt
index 883568ef..2ba290cf 100644
--- a/plugins/templating/src/main/kotlin/templates/PathToRootSubstitutor.kt
+++ b/plugins/templating/src/main/kotlin/templates/PathToRootSubstitutor.kt
@@ -9,7 +9,9 @@ import org.jetbrains.dokka.base.templating.SubstitutionCommand
import org.jetbrains.dokka.plugability.DokkaContext
import java.io.File
-class PathToRootSubstitutor(private val dokkaContext: DokkaContext) : Substitutor {
+public class PathToRootSubstitutor(
+ private val dokkaContext: DokkaContext
+) : Substitutor {
override fun trySubstitute(context: TemplatingContext<SubstitutionCommand>, match: MatchResult): String? =
if (context.command is PathToRootSubstitutionCommand) {
diff --git a/plugins/templating/src/main/kotlin/templates/ProjectNameSubstitutor.kt b/plugins/templating/src/main/kotlin/templates/ProjectNameSubstitutor.kt
index 52d980fb..9b22f31b 100644
--- a/plugins/templating/src/main/kotlin/templates/ProjectNameSubstitutor.kt
+++ b/plugins/templating/src/main/kotlin/templates/ProjectNameSubstitutor.kt
@@ -10,7 +10,9 @@ import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.templates.Substitutor
import org.jetbrains.dokka.templates.TemplatingContext
-class ProjectNameSubstitutor(private val dokkaContext: DokkaContext) : Substitutor {
+public class ProjectNameSubstitutor(
+ private val dokkaContext: DokkaContext
+) : Substitutor {
override fun trySubstitute(context: TemplatingContext<SubstitutionCommand>, match: MatchResult): String? =
dokkaContext.configuration.moduleName.takeIf { context.command is ProjectNameSubstitutionCommand }
diff --git a/plugins/templating/src/main/kotlin/templates/ReplaceVersionCommandHandler.kt b/plugins/templating/src/main/kotlin/templates/ReplaceVersionCommandHandler.kt
index ec441226..28820278 100644
--- a/plugins/templating/src/main/kotlin/templates/ReplaceVersionCommandHandler.kt
+++ b/plugins/templating/src/main/kotlin/templates/ReplaceVersionCommandHandler.kt
@@ -12,7 +12,9 @@ import org.jsoup.nodes.Element
import org.jsoup.nodes.TextNode
import java.io.File
-class ReplaceVersionCommandHandler(private val context: DokkaContext) : CommandHandler {
+public class ReplaceVersionCommandHandler(
+ private val context: DokkaContext
+) : CommandHandler {
override fun canHandle(command: Command): Boolean = command is ReplaceVersionsCommand
diff --git a/plugins/templating/src/main/kotlin/templates/SourcesetDependencyProcessingStrategy.kt b/plugins/templating/src/main/kotlin/templates/SourcesetDependencyProcessingStrategy.kt
index 2a70c520..38a08eea 100644
--- a/plugins/templating/src/main/kotlin/templates/SourcesetDependencyProcessingStrategy.kt
+++ b/plugins/templating/src/main/kotlin/templates/SourcesetDependencyProcessingStrategy.kt
@@ -15,7 +15,9 @@ import java.util.concurrent.ConcurrentHashMap
private typealias Entry = Map<String, List<String>>
-class SourcesetDependencyProcessingStrategy(val context: DokkaContext) : TemplateProcessingStrategy {
+public class SourcesetDependencyProcessingStrategy(
+ public val context: DokkaContext
+) : TemplateProcessingStrategy {
private val fileName = "sourceset_dependencies.js"
private val fragments = ConcurrentHashMap<String, Entry>()
diff --git a/plugins/templating/src/main/kotlin/templates/SubstitutionCommandHandler.kt b/plugins/templating/src/main/kotlin/templates/SubstitutionCommandHandler.kt
index 3ca2568b..0c030439 100644
--- a/plugins/templating/src/main/kotlin/templates/SubstitutionCommandHandler.kt
+++ b/plugins/templating/src/main/kotlin/templates/SubstitutionCommandHandler.kt
@@ -15,7 +15,7 @@ import org.jsoup.nodes.Node
import org.jsoup.nodes.TextNode
import java.io.File
-class SubstitutionCommandHandler(context: DokkaContext) : CommandHandler {
+public class SubstitutionCommandHandler(context: DokkaContext) : CommandHandler {
override fun handleCommandAsTag(command: Command, body: Element, input: File, output: File) {
command as SubstitutionCommand
diff --git a/plugins/templating/src/main/kotlin/templates/Substitutor.kt b/plugins/templating/src/main/kotlin/templates/Substitutor.kt
index b33f585d..4dc4d353 100644
--- a/plugins/templating/src/main/kotlin/templates/Substitutor.kt
+++ b/plugins/templating/src/main/kotlin/templates/Substitutor.kt
@@ -6,6 +6,6 @@ package org.jetbrains.dokka.templates
import org.jetbrains.dokka.base.templating.SubstitutionCommand
-fun interface Substitutor {
- fun trySubstitute(context: TemplatingContext<SubstitutionCommand>, match: MatchResult): String?
+public fun interface Substitutor {
+ public fun trySubstitute(context: TemplatingContext<SubstitutionCommand>, match: MatchResult): String?
}
diff --git a/plugins/templating/src/main/kotlin/templates/TemplateProcessor.kt b/plugins/templating/src/main/kotlin/templates/TemplateProcessor.kt
index 2cbbc215..762e3c8b 100644
--- a/plugins/templating/src/main/kotlin/templates/TemplateProcessor.kt
+++ b/plugins/templating/src/main/kotlin/templates/TemplateProcessor.kt
@@ -19,22 +19,22 @@ import org.jetbrains.dokka.plugability.querySingle
import org.jsoup.nodes.Node
import java.io.File
-interface TemplateProcessor
+public interface TemplateProcessor
-interface SubmoduleTemplateProcessor : TemplateProcessor {
- fun process(modules: List<DokkaModuleDescription>): TemplatingResult
+public interface SubmoduleTemplateProcessor : TemplateProcessor {
+ public fun process(modules: List<DokkaModuleDescription>): TemplatingResult
}
-interface MultiModuleTemplateProcessor : TemplateProcessor {
- fun process(generatedPagesTree: RootPageNode)
+public interface MultiModuleTemplateProcessor : TemplateProcessor {
+ public fun process(generatedPagesTree: RootPageNode)
}
-interface TemplateProcessingStrategy {
- fun process(input: File, output: File, moduleContext: DokkaModuleDescription?): Boolean
- fun finish(output: File) {}
+public interface TemplateProcessingStrategy {
+ public fun process(input: File, output: File, moduleContext: DokkaModuleDescription?): Boolean
+ public fun finish(output: File) {}
}
-class DefaultSubmoduleTemplateProcessor(
+public class DefaultSubmoduleTemplateProcessor(
private val context: DokkaContext,
) : SubmoduleTemplateProcessor {
@@ -44,14 +44,15 @@ class DefaultSubmoduleTemplateProcessor(
private val configuredModulesPaths =
context.configuration.modules.associate { it.sourceOutputDirectory.absolutePath to it.name }
- override fun process(modules: List<DokkaModuleDescription>) =
- runBlocking(Dispatchers.Default) {
+ override fun process(modules: List<DokkaModuleDescription>): TemplatingResult {
+ return runBlocking(Dispatchers.Default) {
coroutineScope {
modules.fold(TemplatingResult()) { acc, module ->
acc + module.sourceOutputDirectory.visit(context.configuration.outputDir.resolve(module.relativePathToOutputDirectory), module)
}
}
}
+ }
private suspend fun File.visit(target: File, module: DokkaModuleDescription, acc: TemplatingResult = TemplatingResult()): TemplatingResult =
coroutineScope {
@@ -74,8 +75,8 @@ class DefaultSubmoduleTemplateProcessor(
}
}
-class DefaultMultiModuleTemplateProcessor(
- val context: DokkaContext,
+public class DefaultMultiModuleTemplateProcessor(
+ public val context: DokkaContext,
) : MultiModuleTemplateProcessor {
private val strategies: List<TemplateProcessingStrategy> =
context.plugin<TemplatingPlugin>().query { templateProcessingStrategy }
@@ -89,13 +90,15 @@ class DefaultMultiModuleTemplateProcessor(
}
}
-data class TemplatingContext<out T : Command>(
+public data class TemplatingContext<out T : Command>(
val input: File,
val output: File,
val body: List<Node>,
val command: T,
)
-data class TemplatingResult(val modules: List<String> = emptyList()) {
- operator fun plus(rhs: TemplatingResult): TemplatingResult = TemplatingResult((modules + rhs.modules).distinct())
+public data class TemplatingResult(val modules: List<String> = emptyList()) {
+ public operator fun plus(rhs: TemplatingResult): TemplatingResult {
+ return TemplatingResult((modules + rhs.modules).distinct())
+ }
}
diff --git a/plugins/templating/src/main/kotlin/templates/TemplatingPlugin.kt b/plugins/templating/src/main/kotlin/templates/TemplatingPlugin.kt
index a8d126d0..8a2e5a2a 100644
--- a/plugins/templating/src/main/kotlin/templates/TemplatingPlugin.kt
+++ b/plugins/templating/src/main/kotlin/templates/TemplatingPlugin.kt
@@ -6,74 +6,71 @@ package org.jetbrains.dokka.templates
import org.jetbrains.dokka.allModulesPage.templates.PackageListProcessingStrategy
import org.jetbrains.dokka.allModulesPage.templates.PagesSearchTemplateStrategy
-import org.jetbrains.dokka.plugability.DokkaPlugin
-import org.jetbrains.dokka.plugability.DokkaPluginApiPreview
-import org.jetbrains.dokka.plugability.PluginApiPreviewAcknowledgement
+import org.jetbrains.dokka.plugability.*
import templates.ProjectNameSubstitutor
import templates.ReplaceVersionCommandHandler
import templates.SourcesetDependencyProcessingStrategy
@Suppress("unused")
-class TemplatingPlugin : DokkaPlugin() {
+public class TemplatingPlugin : DokkaPlugin() {
- val submoduleTemplateProcessor by extensionPoint<SubmoduleTemplateProcessor>()
- val multimoduleTemplateProcessor by extensionPoint<MultiModuleTemplateProcessor>()
- val templateProcessingStrategy by extensionPoint<TemplateProcessingStrategy>()
- val directiveBasedCommandHandlers by extensionPoint<CommandHandler>()
+ public val submoduleTemplateProcessor: ExtensionPoint<SubmoduleTemplateProcessor> by extensionPoint()
+ public val multimoduleTemplateProcessor: ExtensionPoint<MultiModuleTemplateProcessor> by extensionPoint()
+ public val templateProcessingStrategy: ExtensionPoint<TemplateProcessingStrategy> by extensionPoint()
+ public val directiveBasedCommandHandlers: ExtensionPoint<CommandHandler> by extensionPoint()
+ public val substitutor: ExtensionPoint<Substitutor> by extensionPoint()
- val substitutor by extensionPoint<Substitutor>()
-
- val defaultSubmoduleTemplateProcessor by extending {
+ public val defaultSubmoduleTemplateProcessor: Extension<SubmoduleTemplateProcessor, *, *> by extending {
submoduleTemplateProcessor providing ::DefaultSubmoduleTemplateProcessor
}
- val defaultMultiModuleTemplateProcessor by extending {
+ public val defaultMultiModuleTemplateProcessor: Extension<MultiModuleTemplateProcessor, *, *> by extending {
multimoduleTemplateProcessor providing ::DefaultMultiModuleTemplateProcessor
}
- val directiveBasedHtmlTemplateProcessingStrategy by extending {
+ public val directiveBasedHtmlTemplateProcessingStrategy: Extension<TemplateProcessingStrategy, *, *> by extending {
templateProcessingStrategy providing ::DirectiveBasedHtmlTemplateProcessingStrategy order {
before(fallbackProcessingStrategy)
}
}
- val sourcesetDependencyProcessingStrategy by extending {
+ public val sourcesetDependencyProcessingStrategy: Extension<TemplateProcessingStrategy, *, *> by extending {
templateProcessingStrategy providing ::SourcesetDependencyProcessingStrategy order {
before(fallbackProcessingStrategy)
}
}
- val pagesSearchTemplateStrategy by extending {
+ public val pagesSearchTemplateStrategy: Extension<TemplateProcessingStrategy, *, *> by extending {
templateProcessingStrategy providing ::PagesSearchTemplateStrategy order {
before(fallbackProcessingStrategy)
}
}
- val packageListProcessingStrategy by extending {
+ public val packageListProcessingStrategy: Extension<TemplateProcessingStrategy, *, *> by extending {
templateProcessingStrategy providing ::PackageListProcessingStrategy order {
before(fallbackProcessingStrategy)
}
}
- val fallbackProcessingStrategy by extending {
+ public val fallbackProcessingStrategy: Extension<TemplateProcessingStrategy, *, *> by extending {
templateProcessingStrategy with FallbackTemplateProcessingStrategy()
}
- val pathToRootSubstitutor by extending {
+ public val pathToRootSubstitutor: Extension<Substitutor, *, *> by extending {
substitutor providing ::PathToRootSubstitutor
}
- val projectNameSubstitutor by extending {
+ public val projectNameSubstitutor: Extension<Substitutor, *, *> by extending {
substitutor providing ::ProjectNameSubstitutor
}
- val addToNavigationCommandHandler by extending {
+ public val addToNavigationCommandHandler: Extension<CommandHandler, *, *> by extending {
directiveBasedCommandHandlers providing ::AddToNavigationCommandHandler
}
- val substitutionCommandHandler by extending {
+ public val substitutionCommandHandler: Extension<CommandHandler, *, *> by extending {
directiveBasedCommandHandlers providing ::SubstitutionCommandHandler
}
- val replaceVersionCommandHandler by extending {
+ public val replaceVersionCommandHandler: Extension<CommandHandler, *, *> by extending {
directiveBasedCommandHandlers providing ::ReplaceVersionCommandHandler
}