diff options
author | Vadim Mishenev <vad-mishenev@yandex.ru> | 2023-08-08 17:15:51 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-08 17:15:51 +0300 |
commit | 2fd8e9096706545f8b77e1e66bcc876d7e29f82c (patch) | |
tree | ae26f4e51569440928692859d5ecd11ade69e587 /subprojects/analysis-kotlin-api/src/main | |
parent | 80549e1f061d1eb22b12fc9a068536655ae299f7 (diff) | |
download | dokka-2fd8e9096706545f8b77e1e66bcc876d7e29f82c.tar.gz dokka-2fd8e9096706545f8b77e1e66bcc876d7e29f82c.tar.bz2 dokka-2fd8e9096706545f8b77e1e66bcc876d7e29f82c.zip |
Fix and refactor Sample Transformer (#3102)
Diffstat (limited to 'subprojects/analysis-kotlin-api/src/main')
2 files changed, 32 insertions, 0 deletions
diff --git a/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/internal/InternalKotlinAnalysisPlugin.kt b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/internal/InternalKotlinAnalysisPlugin.kt index 330522f3..30c2c2f8 100644 --- a/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/internal/InternalKotlinAnalysisPlugin.kt +++ b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/internal/InternalKotlinAnalysisPlugin.kt @@ -26,6 +26,8 @@ class InternalKotlinAnalysisPlugin : DokkaPlugin() { val documentableSourceLanguageParser by extensionPoint<DocumentableSourceLanguageParser>() + val sampleProviderFactory by extensionPoint<SampleProviderFactory>() + @OptIn(DokkaPluginApiPreview::class) override fun pluginApiPreviewAcknowledgement(): PluginApiPreviewAcknowledgement = PluginApiPreviewAcknowledgement } diff --git a/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/internal/SampleProvider.kt b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/internal/SampleProvider.kt new file mode 100644 index 00000000..195f3c35 --- /dev/null +++ b/subprojects/analysis-kotlin-api/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/internal/SampleProvider.kt @@ -0,0 +1,30 @@ +package org.jetbrains.dokka.analysis.kotlin.internal + +import org.jetbrains.dokka.DokkaConfiguration +import org.jetbrains.dokka.InternalDokkaApi + +@InternalDokkaApi +interface SampleProviderFactory { + /** + * [SampleProvider] is a short-lived closeable instance. + * It assumes that [SampleProvider] scope of use is not big. + * Otherwise, it can lead to high memory consumption / leaks during Dokka running. + */ + fun build(): SampleProvider +} + +/** + * It is closeable. + * Otherwise, there is a chance of high memory consumption / leak. + * In general case, it creates a separate project to analysis samples directories. + */ +@InternalDokkaApi +interface SampleProvider: AutoCloseable { + class SampleSnippet(val imports: String, val body:String) + + + /** + * @return [SampleSnippet] or null if it has not found by [fqLink] + */ + fun getSample(sourceSet: DokkaConfiguration.DokkaSourceSet, fqLink: String): SampleSnippet? +}
\ No newline at end of file |