From 2a097104382a58eb77433c8d7742f4c90987e9f6 Mon Sep 17 00:00:00 2001 From: vmishenev Date: Mon, 1 Nov 2021 18:02:07 +0300 Subject: [PATCH] Use sourceRoots as samples dirs by default --- .../transformers/pages/samples/SamplesTransformer.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt index 88b88cf82d..43252be3d8 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt @@ -7,6 +7,7 @@ import org.jetbrains.dokka.analysis.AnalysisEnvironment import org.jetbrains.dokka.analysis.DokkaMessageCollector import org.jetbrains.dokka.analysis.DokkaResolutionFacade import org.jetbrains.dokka.analysis.EnvironmentAndFacade +import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.renderers.sourceSets import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.DisplaySourceSet @@ -14,6 +15,8 @@ import org.jetbrains.dokka.model.doc.Sample import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext +import org.jetbrains.dokka.plugability.plugin +import org.jetbrains.dokka.plugability.querySingle import org.jetbrains.dokka.transformers.pages.PageTransformer import org.jetbrains.kotlin.idea.kdoc.resolveKDocSampleLink import org.jetbrains.kotlin.name.FqName @@ -44,7 +47,9 @@ abstract class SamplesTransformer(val context: DokkaContext) : PageTransformer { } private fun setUpAnalysis(context: DokkaContext) = context.configuration.sourceSets.map { sourceSet -> - sourceSet to AnalysisEnvironment(DokkaMessageCollector(context.logger), sourceSet.analysisPlatform).run { + sourceSet to if (sourceSet.samples.isEmpty()) context.plugin() + .querySingle { kotlinAnalysis }[sourceSet] // from sourceSet.sourceRoots + else AnalysisEnvironment(DokkaMessageCollector(context.logger), sourceSet.analysisPlatform).run { if (analysisPlatform == Platform.jvm) { addClasspath(PathUtil.getJdkClassesRootsFromCurrentJre()) }