diff options
author | Paweł Marks <pmarks@virtuslab.com> | 2019-11-14 15:18:56 +0100 |
---|---|---|
committer | Błażej Kardyś <bkardys@virtuslab.com> | 2019-11-25 16:24:16 +0100 |
commit | dac6ba2a589aa1e8a9f4a9c7af32026be77776b3 (patch) | |
tree | f7be54609c482f0a0e5b021db38410c0dee8a82f /core/src | |
parent | d3bd543f569656e66112e584ad86af95ae7ea000 (diff) | |
download | dokka-dac6ba2a589aa1e8a9f4a9c7af32026be77776b3.tar.gz dokka-dac6ba2a589aa1e8a9f4a9c7af32026be77776b3.tar.bz2 dokka-dac6ba2a589aa1e8a9f4a9c7af32026be77776b3.zip |
First plugin draft
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/main/kotlin/DokkaGenerator.kt | 14 | ||||
-rw-r--r-- | core/src/main/kotlin/plugability/DokkaContext.kt | 27 | ||||
-rw-r--r-- | core/src/main/kotlin/plugability/DokkaPlugin.kt | 6 |
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 |