aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin
diff options
context:
space:
mode:
authorSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2016-12-27 16:07:17 +0300
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2017-01-13 19:52:30 +0300
commit55fbf4f5ce051396de00b02dad3f3c57368d3685 (patch)
tree13009c3ddd56ccd377fa23f395e3678ea6b41108 /core/src/main/kotlin
parentf47798e7a740839f8a4ccdab9b96582c3a921eaf (diff)
downloaddokka-55fbf4f5ce051396de00b02dad3f3c57368d3685.tar.gz
dokka-55fbf4f5ce051396de00b02dad3f3c57368d3685.tar.bz2
dokka-55fbf4f5ce051396de00b02dad3f3c57368d3685.zip
Drop import samples.* for website-samples
Diffstat (limited to 'core/src/main/kotlin')
-rw-r--r--core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt21
1 files changed, 18 insertions, 3 deletions
diff --git a/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt b/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt
index 648a6b67..baf44904 100644
--- a/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt
+++ b/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt
@@ -2,10 +2,9 @@ package org.jetbrains.dokka.Samples
import com.google.inject.Inject
import com.intellij.psi.PsiElement
-import org.jetbrains.dokka.DocumentationOptions
-import org.jetbrains.dokka.DokkaLogger
-import org.jetbrains.dokka.DokkaResolutionFacade
+import org.jetbrains.dokka.*
import org.jetbrains.kotlin.psi.*
+import org.jetbrains.kotlin.resolve.ImportPath
open class KotlinWebsiteSampleProcessingService
@Inject constructor(options: DocumentationOptions,
@@ -65,6 +64,22 @@ open class KotlinWebsiteSampleProcessingService
return sampleBuilder.text
}
+ val importsToIgnore = arrayOf("samples.*").map(::ImportPath)
+
+ override fun processImports(psiElement: PsiElement): ContentBlockCode {
+ val psiFile = psiElement.containingFile
+ if (psiFile is KtFile) {
+ return ContentBlockCode("kotlin").apply {
+ psiFile.importList?.let {
+ it.children.filter {
+ it !is KtImportDirective || it.importPath !in importsToIgnore
+ }.forEach { append(ContentText(it.text)) }
+ }
+ }
+ }
+ return super.processImports(psiElement)
+ }
+
override fun processSampleBody(psiElement: PsiElement) = when (psiElement) {
is KtDeclarationWithBody -> {
val bodyExpression = psiElement.bodyExpression