diff options
4 files changed, 16 insertions, 8 deletions
diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt index fef71aab..a31c04a6 100644 --- a/core/src/main/kotlin/DokkaGenerator.kt +++ b/core/src/main/kotlin/DokkaGenerator.kt @@ -6,10 +6,10 @@ import com.intellij.psi.PsiManager import org.jetbrains.dokka.analysis.AnalysisEnvironment import org.jetbrains.dokka.analysis.DokkaResolutionFacade import org.jetbrains.dokka.model.Module -import org.jetbrains.dokka.pages.ModulePageNode import org.jetbrains.dokka.pages.PlatformData import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaContext +import org.jetbrains.dokka.plugability.DokkaPlugin import org.jetbrains.dokka.plugability.single import org.jetbrains.dokka.utilities.DokkaLogger import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys @@ -66,8 +66,9 @@ class DokkaGenerator( fun initializePlugins( configuration: DokkaConfiguration, logger: DokkaLogger, - platforms: Map<PlatformData, EnvironmentAndFacade> - ) = DokkaContext.create(configuration, logger, platforms) + platforms: Map<PlatformData, EnvironmentAndFacade>, + pluginOverrides: List<DokkaPlugin> = emptyList() + ) = DokkaContext.create(configuration, logger, platforms, pluginOverrides) fun createDocumentationModels( platforms: Map<PlatformData, EnvironmentAndFacade>, diff --git a/core/src/main/kotlin/plugability/DokkaContext.kt b/core/src/main/kotlin/plugability/DokkaContext.kt index e6286f0b..6a8ac4a3 100644 --- a/core/src/main/kotlin/plugability/DokkaContext.kt +++ b/core/src/main/kotlin/plugability/DokkaContext.kt @@ -25,7 +25,8 @@ interface DokkaContext { fun create( configuration: DokkaConfiguration, logger: DokkaLogger, - platforms: Map<PlatformData, EnvironmentAndFacade> + platforms: Map<PlatformData, EnvironmentAndFacade>, + pluginOverrides: List<DokkaPlugin> ): DokkaContext = DokkaContextConfigurationImpl(logger, configuration, platforms).apply { configuration.pluginsClasspath.map { it.relativeTo(File(".").absoluteFile).toURI().toURL() } @@ -33,6 +34,7 @@ interface DokkaContext { .let { URLClassLoader(it, this.javaClass.classLoader) } .also { checkClasspath(it) } .let { ServiceLoader.load(DokkaPlugin::class.java, it) } + .let { it + pluginOverrides } .forEach { install(it) } applyExtensions() }.also { it.logInitialisationInfo() } diff --git a/testApi/src/main/kotlin/testApi/testRunner/DokkaTestGenerator.kt b/testApi/src/main/kotlin/testApi/testRunner/DokkaTestGenerator.kt index 50e88f2b..21bbe72d 100644 --- a/testApi/src/main/kotlin/testApi/testRunner/DokkaTestGenerator.kt +++ b/testApi/src/main/kotlin/testApi/testRunner/DokkaTestGenerator.kt @@ -4,12 +4,14 @@ import org.jetbrains.dokka.DokkaConfiguration import org.jetbrains.dokka.DokkaGenerator import org.jetbrains.dokka.EnvironmentAndFacade import org.jetbrains.dokka.pages.PlatformData +import org.jetbrains.dokka.plugability.DokkaPlugin import org.jetbrains.dokka.utilities.DokkaLogger internal class DokkaTestGenerator( private val configuration: DokkaConfiguration, private val logger: DokkaLogger, - private val testMethods: TestMethods + private val testMethods: TestMethods, + private val pluginOverrides: List<DokkaPlugin> = emptyList() ) { fun generate() = with(testMethods) { @@ -18,7 +20,7 @@ internal class DokkaTestGenerator( val platforms: Map<PlatformData, EnvironmentAndFacade> = dokkaGenerator.setUpAnalysis(configuration) analysisSetupStage(platforms) - val context = dokkaGenerator.initializePlugins(configuration, logger, platforms) + val context = dokkaGenerator.initializePlugins(configuration, logger, platforms, pluginOverrides) pluginsSetupStage(context) val modulesFromPlatforms = dokkaGenerator.createDocumentationModels(platforms, context) diff --git a/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt b/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt index fa61bf59..b8817918 100644 --- a/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt +++ b/testApi/src/main/kotlin/testApi/testRunner/TestRunner.kt @@ -6,6 +6,7 @@ import org.jetbrains.dokka.pages.ModulePageNode import org.jetbrains.dokka.pages.PlatformData import org.jetbrains.dokka.pages.RootPageNode import org.jetbrains.dokka.plugability.DokkaContext +import org.jetbrains.dokka.plugability.DokkaPlugin import org.jetbrains.dokka.utilities.DokkaConsoleLogger import org.junit.rules.TemporaryFolder import java.io.File @@ -26,6 +27,7 @@ abstract class AbstractCoreTest { protected fun testFromData( configuration: DokkaConfigurationImpl, cleanupOutput: Boolean = true, + pluginOverrides: List<DokkaPlugin> = emptyList(), block: TestBuilder.() -> Unit ) { val testMethods = TestBuilder().apply(block).build() @@ -36,13 +38,14 @@ abstract class AbstractCoreTest { configuration.copy( outputDir = tempDir.root.toPath().toAbsolutePath().toString() ) - DokkaTestGenerator(newConfiguration, logger, testMethods).generate() + DokkaTestGenerator(newConfiguration, logger, testMethods, pluginOverrides).generate() } protected fun testInline( query: String, configuration: DokkaConfigurationImpl, cleanupOutput: Boolean = true, + pluginOverrides: List<DokkaPlugin> = emptyList(), block: TestBuilder.() -> Unit ) { val testMethods = TestBuilder().apply(block).build() @@ -57,7 +60,7 @@ abstract class AbstractCoreTest { passesConfigurations = configuration.passesConfigurations .map { it.copy(sourceRoots = it.sourceRoots.map { it.copy(path = "${testDirPath.toAbsolutePath()}/${it.path}") }) } ) - DokkaTestGenerator(newConfiguration, logger, testMethods).generate() + DokkaTestGenerator(newConfiguration, logger, testMethods, pluginOverrides).generate() } private fun String.toFileMap(): Map<String, String> = this.trimMargin().removePrefix("|") |