diff options
author | Vadim Mishenev <vad-mishenev@yandex.ru> | 2021-12-17 13:21:30 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-17 13:21:30 +0300 |
commit | 702c102b934208792a380d8a984052801f9230a1 (patch) | |
tree | b603c08b0ce59c8ccaf15254a73efa2cbd08f5ab /plugins/base/src/main/kotlin/transformers/pages/samples | |
parent | a485ca9eca9d4465a800dfa042417c6fc16a2896 (diff) | |
download | dokka-702c102b934208792a380d8a984052801f9230a1.tar.gz dokka-702c102b934208792a380d8a984052801f9230a1.tar.bz2 dokka-702c102b934208792a380d8a984052801f9230a1.zip |
Use sourceRoots as samples dirs by default (#2216)
Diffstat (limited to 'plugins/base/src/main/kotlin/transformers/pages/samples')
-rw-r--r-- | plugins/base/src/main/kotlin/transformers/pages/samples/SamplesTransformer.kt | 7 |
1 files changed, 6 insertions, 1 deletions
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 88b88cf8..43252be3 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<DokkaBase>() + .querySingle { kotlinAnalysis }[sourceSet] // from sourceSet.sourceRoots + else AnalysisEnvironment(DokkaMessageCollector(context.logger), sourceSet.analysisPlatform).run { if (analysisPlatform == Platform.jvm) { addClasspath(PathUtil.getJdkClassesRootsFromCurrentJre()) } |