aboutsummaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/kotlin/DokkaGenerator.kt14
-rw-r--r--core/src/main/kotlin/plugability/DokkaContext.kt27
-rw-r--r--core/src/main/kotlin/plugability/DokkaPlugin.kt6
3 files changed, 46 insertions, 1 deletions
diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt
index 11f583b3..a522ea40 100644
--- a/core/src/main/kotlin/DokkaGenerator.kt
+++ b/core/src/main/kotlin/DokkaGenerator.kt
@@ -2,11 +2,11 @@ package org.jetbrains.dokka
import org.jetbrains.dokka.Model.Module
import org.jetbrains.dokka.Model.transformers.DocumentationNodesMerger
-//import org.jetbrains.dokka.Utilities.genericPretty
import org.jetbrains.dokka.Utilities.pretty
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.pages.MarkdownToContentConverter
import org.jetbrains.dokka.pages.PlatformData
+import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.renderers.FileWriter
import org.jetbrains.dokka.renderers.HtmlRenderer
import org.jetbrains.dokka.resolvers.DefaultLocationProvider
@@ -23,6 +23,18 @@ class DokkaGenerator(
private val logger: DokkaLogger
) {
fun generate(): Unit {
+
+ logger.info("Initializing plugins")
+ val context = DokkaContext.from(configuration.pluginsClasspath)
+ context.pluginNames.also { names ->
+ logger.info("Loaded plugins: $names")
+ names.groupingBy { it }.eachCount().filter { it.value > 1 }.forEach {
+ logger.warn("Duplicate plugin name: ${it.key}. It will make debugging much harder.")
+ }
+ }
+
+
+
configuration.passesConfigurations.map { pass ->
AnalysisEnvironment(DokkaMessageCollector(logger), pass.analysisPlatform).run {
if (analysisPlatform == Platform.jvm) {
diff --git a/core/src/main/kotlin/plugability/DokkaContext.kt b/core/src/main/kotlin/plugability/DokkaContext.kt
new file mode 100644
index 00000000..7da4d9a7
--- /dev/null
+++ b/core/src/main/kotlin/plugability/DokkaContext.kt
@@ -0,0 +1,27 @@
+package org.jetbrains.dokka.plugability
+
+import java.io.File
+import java.net.URLClassLoader
+import java.util.*
+
+
+class DokkaContext private constructor() {
+ private val plugins = mutableListOf<DokkaPlugin>()
+
+ val pluginNames: List<String>
+ get() = plugins.map { it.name }
+
+ private fun install(plugin: DokkaPlugin) {
+ plugins += plugin
+ plugin.install(this)
+ }
+
+ companion object {
+ fun from(pluginsClasspath: Iterable<File>) = DokkaContext().apply {
+ pluginsClasspath.map { it.relativeTo(File(".").absoluteFile).toURI().toURL() }
+ .toTypedArray()
+ .let { ServiceLoader.load(DokkaPlugin::class.java, URLClassLoader(it, this.javaClass.classLoader)) }
+ .forEach { install(it) }
+ }
+ }
+} \ No newline at end of file
diff --git a/core/src/main/kotlin/plugability/DokkaPlugin.kt b/core/src/main/kotlin/plugability/DokkaPlugin.kt
new file mode 100644
index 00000000..2654bcee
--- /dev/null
+++ b/core/src/main/kotlin/plugability/DokkaPlugin.kt
@@ -0,0 +1,6 @@
+package org.jetbrains.dokka.plugability
+
+interface DokkaPlugin {
+ val name: String
+ fun install(context: DokkaContext)
+} \ No newline at end of file