aboutsummaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2018-02-22 14:31:12 +0300
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2018-02-22 14:31:12 +0300
commitf37d9c3bdd91c5af683eb7eaaf242d7af3d6fcf1 (patch)
treeb9039596c118469ef4f9151eee195a50c0cac4f1 /core/src
parent79a7a136bdc3a59d7bb3aebb51e565b58e2b789c (diff)
parent3eb23215edcd1cf92966f8d39afe754fef0c7a19 (diff)
downloaddokka-f37d9c3bdd91c5af683eb7eaaf242d7af3d6fcf1.tar.gz
dokka-f37d9c3bdd91c5af683eb7eaaf242d7af3d6fcf1.tar.bz2
dokka-f37d9c3bdd91c5af683eb7eaaf242d7af3d6fcf1.zip
Merge branch 'dev'
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/kotlin/Analysis/AnalysisEnvironment.kt76
-rw-r--r--core/src/main/kotlin/Analysis/CoreKotlinCacheService.kt30
-rw-r--r--core/src/main/kotlin/Analysis/CoreProjectFileIndex.kt46
-rw-r--r--core/src/main/kotlin/DokkaBootstrapImpl.kt5
-rw-r--r--core/src/main/kotlin/Formats/FormatDescriptor.kt2
-rw-r--r--core/src/main/kotlin/Formats/StandardFormats.kt5
-rw-r--r--core/src/main/kotlin/Formats/StructuredFormatService.kt25
-rw-r--r--core/src/main/kotlin/Generation/DokkaGenerator.kt2
-rw-r--r--core/src/main/kotlin/Generation/configurationImpl.kt49
-rw-r--r--core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt13
-rw-r--r--core/src/main/kotlin/Kotlin/ContentBuilder.kt9
-rw-r--r--core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt22
-rw-r--r--core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt2
-rw-r--r--core/src/main/kotlin/Kotlin/DocumentationBuilder.kt59
-rw-r--r--core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt42
-rw-r--r--core/src/main/kotlin/Kotlin/KotlinAsJavaDescriptorSignatureProvider.kt22
-rw-r--r--core/src/main/kotlin/Kotlin/KotlinDescriptorSignatureProvider.kt9
-rw-r--r--core/src/main/kotlin/Model/DescriptorSignatureProvider.kt7
-rw-r--r--core/src/main/kotlin/Model/PackageDocs.kt5
-rw-r--r--core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt14
-rw-r--r--core/src/main/kotlin/Utilities/DokkaModules.kt3
-rw-r--r--core/src/main/kotlin/javadoc/dokka-adapters.kt3
-rw-r--r--core/src/test/java/com/intellij/rt/execution/junit/FileComparisonFailure.java39
-rw-r--r--core/src/test/java/com/intellij/rt/execution/junit/KnownException.java6
-rw-r--r--core/src/test/kotlin/TestAPI.kt35
-rw-r--r--core/src/test/kotlin/format/HtmlFormatTest.kt4
-rw-r--r--core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt9
-rw-r--r--core/src/test/kotlin/format/KotlinWebSiteHtmlFormatTest.kt9
-rw-r--r--core/src/test/kotlin/format/MarkdownFormatTest.kt69
-rw-r--r--core/src/test/kotlin/javadoc/JavadocTest.kt10
-rw-r--r--core/src/test/kotlin/model/FunctionTest.kt14
-rw-r--r--core/src/test/kotlin/model/PackageTest.kt35
32 files changed, 523 insertions, 157 deletions
diff --git a/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt b/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt
index be4285c0..5522d4f0 100644
--- a/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt
+++ b/core/src/main/kotlin/Analysis/AnalysisEnvironment.kt
@@ -1,5 +1,6 @@
package org.jetbrains.dokka
+import com.google.common.collect.ImmutableMap
import com.intellij.core.CoreApplicationEnvironment
import com.intellij.core.CoreModuleManager
import com.intellij.mock.MockComponentManager
@@ -13,11 +14,11 @@ import com.intellij.openapi.roots.ProjectFileIndex
import com.intellij.openapi.roots.ProjectRootManager
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.vfs.StandardFileSystems
-import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.psi.PsiElement
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.util.io.URLUtil
import org.jetbrains.kotlin.analyzer.*
+import org.jetbrains.kotlin.caches.resolve.KotlinCacheService
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
@@ -35,16 +36,19 @@ import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
import org.jetbrains.kotlin.load.java.structure.impl.JavaClassImpl
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.platform.JvmBuiltIns
-import org.jetbrains.kotlin.psi.KtDeclaration
-import org.jetbrains.kotlin.psi.KtElement
-import org.jetbrains.kotlin.psi.KtFile
+import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.BindingContext
+import org.jetbrains.kotlin.resolve.BindingTrace
import org.jetbrains.kotlin.resolve.CompilerEnvironment
+import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics
import org.jetbrains.kotlin.resolve.jvm.JvmAnalyzerFacade
import org.jetbrains.kotlin.resolve.jvm.JvmPlatformParameters
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.resolve.lazy.ResolveSession
+import org.jetbrains.kotlin.types.KotlinType
+import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice
+import org.jetbrains.kotlin.util.slicedMap.WritableSlice
import java.io.File
/**
@@ -114,11 +118,17 @@ class AnalysisEnvironment(val messageCollector: MessageCollector) : Disposable {
val builtIns = JvmBuiltIns(projectContext.storageManager)
- val javaRoots = run {
- val jvfs = VirtualFileManager.getInstance().getFileSystem(StandardFileSystems.JAR_PROTOCOL)
+ val javaRoots = classpath
+ .mapNotNull {
+ val rootFile = when {
+ it.extension == "jar" ->
+ StandardFileSystems.jar().findFileByPath("${it.absolutePath}${URLUtil.JAR_SEPARATOR}")
+ else ->
+ StandardFileSystems.local().findFileByPath(it.absolutePath)
+ }
- classpath.map { JavaRoot(jvfs.findFileByPath("${it.absolutePath}${URLUtil.JAR_SEPARATOR}")!!, JavaRoot.RootType.BINARY) }
- }
+ rootFile?.let { JavaRoot(it, JavaRoot.RootType.BINARY) }
+ }
val resolverForProject = ResolverForProjectImpl(
"Dokka",
@@ -141,7 +151,7 @@ class AnalysisEnvironment(val messageCollector: MessageCollector) : Disposable {
},
CompilerEnvironment,
packagePartProviderFactory = { info, content ->
- JvmPackagePartProvider(LanguageVersionSettingsImpl.DEFAULT, content.moduleContentScope).apply {
+ JvmPackagePartProvider(configuration.languageVersionSettings, content.moduleContentScope).apply {
addRoots(javaRoots)
}
},
@@ -153,7 +163,17 @@ class AnalysisEnvironment(val messageCollector: MessageCollector) : Disposable {
val resolverForModule = resolverForProject.resolverForModule(module)
val moduleDescriptor = resolverForProject.descriptorForModule(module)
builtIns.initialize(moduleDescriptor, true)
- return DokkaResolutionFacade(environment.project, moduleDescriptor, resolverForModule)
+ val created = DokkaResolutionFacade(environment.project, moduleDescriptor, resolverForModule)
+ val projectComponentManager = environment.project as MockComponentManager
+ projectComponentManager.registerService(KotlinCacheService::class.java, CoreKotlinCacheService(created))
+
+ return created
+ }
+
+ fun loadLanguageVersionSettings(languageVersionString: String?, apiVersionString: String?) {
+ val languageVersion = LanguageVersion.fromVersionString(languageVersionString) ?: LanguageVersion.LATEST_STABLE
+ val apiVersion = apiVersionString?.let { ApiVersion.parse(it) } ?: ApiVersion.createByLanguageVersion(languageVersion)
+ configuration.languageVersionSettings = LanguageVersionSettingsImpl(languageVersion, apiVersion)
}
/**
@@ -236,6 +256,42 @@ class DokkaResolutionFacade(override val project: Project,
val resolveSession: ResolveSession get() = getFrontendService(ResolveSession::class.java)
override fun analyze(element: KtElement, bodyResolveMode: BodyResolveMode): BindingContext {
+ if (element is KtDeclaration) {
+ val descriptor = resolveToDescriptor(element)
+ return object : BindingContext {
+ override fun <K : Any?, V : Any?> getKeys(p0: WritableSlice<K, V>?): Collection<K> {
+ throw UnsupportedOperationException()
+ }
+
+ override fun getType(p0: KtExpression): KotlinType? {
+ throw UnsupportedOperationException()
+ }
+
+ override fun <K : Any?, V : Any?> get(slice: ReadOnlySlice<K, V>?, key: K): V? {
+ if (key != element) {
+ throw UnsupportedOperationException()
+ }
+ return when {
+ slice == BindingContext.DECLARATION_TO_DESCRIPTOR -> descriptor as V
+ slice == BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER && (element as KtParameter).hasValOrVar() -> descriptor as V
+ else -> null
+ }
+ }
+
+ override fun getDiagnostics(): Diagnostics {
+ throw UnsupportedOperationException()
+ }
+
+ override fun addOwnDataTo(p0: BindingTrace, p1: Boolean) {
+ throw UnsupportedOperationException()
+ }
+
+ override fun <K : Any?, V : Any?> getSliceContents(p0: ReadOnlySlice<K, V>): ImmutableMap<K, V> {
+ throw UnsupportedOperationException()
+ }
+
+ }
+ }
throw UnsupportedOperationException()
}
diff --git a/core/src/main/kotlin/Analysis/CoreKotlinCacheService.kt b/core/src/main/kotlin/Analysis/CoreKotlinCacheService.kt
new file mode 100644
index 00000000..31b8ffc7
--- /dev/null
+++ b/core/src/main/kotlin/Analysis/CoreKotlinCacheService.kt
@@ -0,0 +1,30 @@
+package org.jetbrains.dokka
+
+import com.intellij.psi.PsiFile
+import org.jetbrains.kotlin.analyzer.ModuleInfo
+import org.jetbrains.kotlin.caches.resolve.KotlinCacheService
+import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
+import org.jetbrains.kotlin.psi.KtElement
+import org.jetbrains.kotlin.resolve.TargetPlatform
+import org.jetbrains.kotlin.resolve.diagnostics.KotlinSuppressCache
+
+
+class CoreKotlinCacheService(private val resolutionFacade: DokkaResolutionFacade) : KotlinCacheService {
+ override fun getResolutionFacade(elements: List<KtElement>): ResolutionFacade {
+ return resolutionFacade
+ }
+
+ override fun getResolutionFacadeByFile(file: PsiFile, platform: TargetPlatform): ResolutionFacade {
+ return resolutionFacade
+ }
+
+ override fun getResolutionFacadeByModuleInfo(moduleInfo: ModuleInfo, platform: TargetPlatform): ResolutionFacade? {
+ return resolutionFacade
+ }
+
+ override fun getSuppressionCache(): KotlinSuppressCache {
+ throw UnsupportedOperationException()
+ }
+
+}
+
diff --git a/core/src/main/kotlin/Analysis/CoreProjectFileIndex.kt b/core/src/main/kotlin/Analysis/CoreProjectFileIndex.kt
index 21f7e2da..4f6a7c76 100644
--- a/core/src/main/kotlin/Analysis/CoreProjectFileIndex.kt
+++ b/core/src/main/kotlin/Analysis/CoreProjectFileIndex.kt
@@ -32,7 +32,11 @@ import java.io.File
* classes from projectModel-{api,impl}.
*/
class CoreProjectFileIndex(private val project: Project, contentRoots: List<ContentRoot>) : ProjectFileIndex, ModuleFileIndex {
- override fun iterateContentUnderDirectory(p0: VirtualFile, p1: ContentIterator, p2: VirtualFileFilter): Boolean {
+ override fun iterateContent(p0: ContentIterator, p1: VirtualFileFilter?): Boolean {
+ throw UnsupportedOperationException()
+ }
+
+ override fun iterateContentUnderDirectory(p0: VirtualFile, p1: ContentIterator, p2: VirtualFileFilter?): Boolean {
throw UnsupportedOperationException()
}
@@ -74,7 +78,7 @@ class CoreProjectFileIndex(private val project: Project, contentRoots: List<Cont
throw UnsupportedOperationException()
}
- override fun setOption(p0: String, p1: String) {
+ override fun setOption(p0: String, p1: String?) {
throw UnsupportedOperationException()
}
@@ -224,24 +228,26 @@ class CoreProjectFileIndex(private val project: Project, contentRoots: List<Cont
}
private val moduleSourceOrderEntry = object : ModuleSourceOrderEntry {
- override fun getFiles(p0: OrderRootType?): Array<out VirtualFile> {
+ override fun getFiles(p0: OrderRootType): Array<VirtualFile> {
throw UnsupportedOperationException()
}
- override fun getPresentableName(): String {
+ override fun getUrls(p0: OrderRootType): Array<String> {
throw UnsupportedOperationException()
}
- override fun getUrls(p0: OrderRootType?): Array<out String> {
+ override fun <R : Any?> accept(p0: RootPolicy<R>, p1: R?): R {
throw UnsupportedOperationException()
}
- override fun getOwnerModule(): Module = module
- override fun <R : Any?> accept(p0: RootPolicy<R>?, p1: R?): R {
+ override fun getPresentableName(): String {
throw UnsupportedOperationException()
}
+ override fun getOwnerModule(): Module = module
+
+
override fun isValid(): Boolean {
throw UnsupportedOperationException()
}
@@ -258,29 +264,29 @@ class CoreProjectFileIndex(private val project: Project, contentRoots: List<Cont
}
private val sdkOrderEntry = object : JdkOrderEntry {
- override fun getJdkName(): String? {
+ override fun getFiles(p0: OrderRootType): Array<VirtualFile> {
throw UnsupportedOperationException()
}
- override fun getJdk(): Sdk = sdk
-
- override fun getFiles(p0: OrderRootType?): Array<out VirtualFile> {
+ override fun getUrls(p0: OrderRootType): Array<String> {
throw UnsupportedOperationException()
}
- override fun getPresentableName(): String {
+ override fun <R : Any?> accept(p0: RootPolicy<R>, p1: R?): R {
throw UnsupportedOperationException()
}
- override fun getUrls(p0: OrderRootType?): Array<out String> {
+ override fun getJdkName(): String? {
throw UnsupportedOperationException()
}
- override fun getOwnerModule(): Module {
+ override fun getJdk(): Sdk = sdk
+
+ override fun getPresentableName(): String {
throw UnsupportedOperationException()
}
- override fun <R : Any?> accept(p0: RootPolicy<R>?, p1: R?): R {
+ override fun getOwnerModule(): Module {
throw UnsupportedOperationException()
}
@@ -288,11 +294,11 @@ class CoreProjectFileIndex(private val project: Project, contentRoots: List<Cont
throw UnsupportedOperationException()
}
- override fun getRootFiles(p0: OrderRootType?): Array<out VirtualFile>? {
+ override fun getRootFiles(p0: OrderRootType): Array<out VirtualFile> {
throw UnsupportedOperationException()
}
- override fun getRootUrls(p0: OrderRootType?): Array<out String>? {
+ override fun getRootUrls(p0: OrderRootType): Array<out String> {
throw UnsupportedOperationException()
}
@@ -307,6 +313,10 @@ class CoreProjectFileIndex(private val project: Project, contentRoots: List<Cont
}
inner class MyModuleRootManager : ModuleRootManager() {
+ override fun getExternalSource(): ProjectModelExternalSource? {
+ throw UnsupportedOperationException()
+ }
+
override fun getExcludeRoots(): Array<out VirtualFile> {
throw UnsupportedOperationException()
}
@@ -350,7 +360,7 @@ class CoreProjectFileIndex(private val project: Project, contentRoots: List<Cont
override fun getRootModel(p0: Module): ModuleRootModel = this@MyModuleRootManager
})
- override fun <T : Any?> getModuleExtension(p0: Class<T>?): T {
+ override fun <T : Any?> getModuleExtension(p0: Class<T>): T {
throw UnsupportedOperationException()
}
diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt
index e9d0f3d5..126a0175 100644
--- a/core/src/main/kotlin/DokkaBootstrapImpl.kt
+++ b/core/src/main/kotlin/DokkaBootstrapImpl.kt
@@ -17,7 +17,8 @@ fun parsePerPackageOptions(arg: String): List<PackageOptions> {
val deprecated = args.find { it.endsWith("deprecated") }?.startsWith("+") ?: true
val reportUndocumented = args.find { it.endsWith("warnUndocumented") }?.startsWith("+") ?: true
val privateApi = args.find { it.endsWith("privateApi") }?.startsWith("+") ?: false
- PackageOptionsImpl(prefix, includeNonPublic = privateApi, reportUndocumented = reportUndocumented, skipDeprecated = !deprecated)
+ val suppress = args.find { it.endsWith("suppress") }?.startsWith("+") ?: false
+ PackageOptionsImpl(prefix, includeNonPublic = privateApi, reportUndocumented = reportUndocumented, skipDeprecated = !deprecated, suppress = suppress)
}
}
@@ -65,6 +66,8 @@ class DokkaBootstrapImpl : DokkaBootstrap {
perPackageOptions,
externalDocumentationLinks,
noStdlibLink,
+ languageVersion,
+ apiVersion,
cacheRoot,
suppressedFiles.map { File(it) }
)
diff --git a/core/src/main/kotlin/Formats/FormatDescriptor.kt b/core/src/main/kotlin/Formats/FormatDescriptor.kt
index fc925f40..da0156a7 100644
--- a/core/src/main/kotlin/Formats/FormatDescriptor.kt
+++ b/core/src/main/kotlin/Formats/FormatDescriptor.kt
@@ -1,6 +1,7 @@
package org.jetbrains.dokka.Formats
import org.jetbrains.dokka.*
+import org.jetbrains.dokka.Model.DescriptorSignatureProvider
import org.jetbrains.dokka.Samples.SampleProcessingService
import kotlin.reflect.KClass
@@ -12,4 +13,5 @@ interface FormatDescriptor {
val javaDocumentationBuilderClass: KClass<out JavaDocumentationBuilder>
val sampleProcessingService: KClass<out SampleProcessingService>
val packageListServiceClass: KClass<out PackageListService>?
+ val descriptorSignatureProvider: KClass<out DescriptorSignatureProvider>
}
diff --git a/core/src/main/kotlin/Formats/StandardFormats.kt b/core/src/main/kotlin/Formats/StandardFormats.kt
index fad65ff1..f3d638c6 100644
--- a/core/src/main/kotlin/Formats/StandardFormats.kt
+++ b/core/src/main/kotlin/Formats/StandardFormats.kt
@@ -1,6 +1,9 @@
package org.jetbrains.dokka.Formats
import org.jetbrains.dokka.*
+import org.jetbrains.dokka.Kotlin.KotlinAsJavaDescriptorSignatureProvider
+import org.jetbrains.dokka.Kotlin.KotlinDescriptorSignatureProvider
+import org.jetbrains.dokka.Model.DescriptorSignatureProvider
import org.jetbrains.dokka.Samples.DefaultSampleProcessingService
import org.jetbrains.dokka.Samples.KotlinWebsiteSampleProcessingService
import org.jetbrains.dokka.Samples.SampleProcessingService
@@ -14,6 +17,7 @@ abstract class KotlinFormatDescriptorBase : FormatDescriptor {
override val outlineServiceClass: KClass<out OutlineFormatService>? = null
override val sampleProcessingService: KClass<out SampleProcessingService> = DefaultSampleProcessingService::class
override val packageListServiceClass: KClass<out PackageListService>? = DefaultPackageListService::class
+ override val descriptorSignatureProvider = KotlinDescriptorSignatureProvider::class
}
class HtmlFormatDescriptor : KotlinFormatDescriptorBase() {
@@ -29,6 +33,7 @@ class HtmlAsJavaFormatDescriptor : FormatDescriptor {
override val javaDocumentationBuilderClass = JavaPsiDocumentationBuilder::class
override val sampleProcessingService: KClass<out SampleProcessingService> = DefaultSampleProcessingService::class
override val packageListServiceClass: KClass<out PackageListService>? = DefaultPackageListService::class
+ override val descriptorSignatureProvider = KotlinAsJavaDescriptorSignatureProvider::class
}
class KotlinWebsiteFormatDescriptor : KotlinFormatDescriptorBase() {
diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt
index a8b000b7..5167a102 100644
--- a/core/src/main/kotlin/Formats/StructuredFormatService.kt
+++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt
@@ -398,10 +398,29 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
else -> it.platformsToShow.toSet()
}
}
+
+ fun String.isKotlinVersion() = this.startsWith("Kotlin")
+
// Calculating common platforms for items
- return platforms.fold(platforms.first()) {
- result, platforms ->
- result.intersect(platforms)
+ return platforms.reduce { result, platformsOfItem ->
+ val otherKotlinVersion = result.find { it.isKotlinVersion() }
+ val (kotlinVersions, otherPlatforms) = platformsOfItem.partition { it.isKotlinVersion() }
+
+ // When no Kotlin version specified, it means that version is 1.0
+ if (otherKotlinVersion != null && kotlinVersions.isNotEmpty()) {
+ val allKotlinVersions = (kotlinVersions + otherKotlinVersion).distinct()
+
+ val minVersion = allKotlinVersions.min()!!
+ val resultVersion = when {
+ allKotlinVersions.size == 1 -> allKotlinVersions.single()
+ minVersion.endsWith("+") -> minVersion
+ else -> minVersion + "+"
+ }
+
+ result.intersect(otherPlatforms) + resultVersion
+ } else {
+ result.intersect(platformsOfItem)
+ }
}
}
diff --git a/core/src/main/kotlin/Generation/DokkaGenerator.kt b/core/src/main/kotlin/Generation/DokkaGenerator.kt
index 17b6b156..09e5cedf 100644
--- a/core/src/main/kotlin/Generation/DokkaGenerator.kt
+++ b/core/src/main/kotlin/Generation/DokkaGenerator.kt
@@ -94,6 +94,8 @@ class DokkaGenerator(val logger: DokkaLogger,
addSources(sourcePaths)
addSources(this@DokkaGenerator.samples)
+
+ loadLanguageVersionSettings(options.languageVersion, options.apiVersion)
}
return environment
diff --git a/core/src/main/kotlin/Generation/configurationImpl.kt b/core/src/main/kotlin/Generation/configurationImpl.kt
index f67582a7..34d4154e 100644
--- a/core/src/main/kotlin/Generation/configurationImpl.kt
+++ b/core/src/main/kotlin/Generation/configurationImpl.kt
@@ -32,26 +32,31 @@ class SourceRootImpl(path: String, override val platforms: List<String> = emptyL
data class PackageOptionsImpl(override val prefix: String,
override val includeNonPublic: Boolean = false,
override val reportUndocumented: Boolean = true,
- override val skipDeprecated: Boolean = false) : DokkaConfiguration.PackageOptions
+ override val skipDeprecated: Boolean = false,
+ override val suppress: Boolean = false) : DokkaConfiguration.PackageOptions
-data class DokkaConfigurationImpl(override val moduleName: String,
- override val classpath: List<String>,
- override val sourceRoots: List<SourceRootImpl>,
- override val samples: List<String>,
- override val includes: List<String>,
- override val outputDir: String,
- override val format: String,
- override val includeNonPublic: Boolean,
- override val includeRootPackage: Boolean,
- override val reportUndocumented: Boolean,
- override val skipEmptyPackages: Boolean,
- override val skipDeprecated: Boolean,
- override val jdkVersion: Int,
- override val generateIndexPages: Boolean,
- override val sourceLinks: List<SourceLinkDefinitionImpl>,
- override val impliedPlatforms: List<String>,
- override val perPackageOptions: List<PackageOptionsImpl>,
- override val externalDocumentationLinks: List<ExternalDocumentationLinkImpl>,
- override val noStdlibLink: Boolean,
- override val cacheRoot: String?,
- override val suppressedFiles: List<String>) : DokkaConfiguration \ No newline at end of file
+data class DokkaConfigurationImpl(
+ override val moduleName: String,
+ override val classpath: List<String>,
+ override val sourceRoots: List<SourceRootImpl>,
+ override val samples: List<String>,
+ override val includes: List<String>,
+ override val outputDir: String,
+ override val format: String,
+ override val includeNonPublic: Boolean,
+ override val includeRootPackage: Boolean,
+ override val reportUndocumented: Boolean,
+ override val skipEmptyPackages: Boolean,
+ override val skipDeprecated: Boolean,
+ override val jdkVersion: Int,
+ override val generateIndexPages: Boolean,
+ override val sourceLinks: List<SourceLinkDefinitionImpl>,
+ override val impliedPlatforms: List<String>,
+ override val perPackageOptions: List<PackageOptionsImpl>,
+ override val externalDocumentationLinks: List<ExternalDocumentationLinkImpl>,
+ override val noStdlibLink: Boolean,
+ override val cacheRoot: String?,
+ override val suppressedFiles: List<String>,
+ override val languageVersion: String?,
+ override val apiVersion: String?
+) : DokkaConfiguration \ No newline at end of file
diff --git a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
index a950e432..cf2b0514 100644
--- a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
+++ b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.kdoc.psi.impl.KDocTag
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.psi.KtModifierListOwner
+import java.io.File
fun getSignature(element: PsiElement?) = when(element) {
is PsiClass -> element.qualifiedName
@@ -57,7 +58,7 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder {
}
override fun appendFile(file: PsiJavaFile, module: DocumentationModule, packageContent: Map<String, Content>) {
- if (file.classes.all { skipElement(it) }) {
+ if (skipFile(file) || file.classes.all { skipElement(it) }) {
return
}
val packageNode = module.findOrCreatePackageNode(file.packageName, emptyMap(), refGraph)
@@ -131,7 +132,12 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder {
}
}
- private fun skipElement(element: Any) = skipElementByVisibility(element) || hasSuppressDocTag(element)
+ private fun skipFile(javaFile: PsiJavaFile): Boolean = options.effectivePackageOptions(javaFile.packageName).suppress
+
+ private fun skipElement(element: Any) =
+ skipElementByVisibility(element) ||
+ hasSuppressDocTag(element) ||
+ skipElementBySuppressedFiles(element)
private fun skipElementByVisibility(element: Any): Boolean = element is PsiModifierListOwner &&
!(options.effectivePackageOptions((element.containingFile as? PsiJavaFile)?.packageName ?: "").includeNonPublic) &&
@@ -139,6 +145,9 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder {
element.hasModifierProperty(PsiModifier.PACKAGE_LOCAL) ||
element.isInternal())
+ private fun skipElementBySuppressedFiles(element: Any): Boolean =
+ element is PsiElement && File(element.containingFile.virtualFile.path).absoluteFile in options.suppressedFiles
+
private fun PsiElement.isInternal(): Boolean {
val ktElement = (this as? KtLightElement<*, *>)?.kotlinOrigin ?: return false
return (ktElement as? KtModifierListOwner)?.hasModifier(KtTokens.INTERNAL_KEYWORD) ?: false
diff --git a/core/src/main/kotlin/Kotlin/ContentBuilder.kt b/core/src/main/kotlin/Kotlin/ContentBuilder.kt
index 771bc44b..c60625a4 100644
--- a/core/src/main/kotlin/Kotlin/ContentBuilder.kt
+++ b/core/src/main/kotlin/Kotlin/ContentBuilder.kt
@@ -110,9 +110,12 @@ fun buildContentTo(tree: MarkdownNode, target: ContentBlock, linkResolver: LinkR
}
MarkdownTokenTypes.CODE_LINE -> {
- val block = ContentBlockCode()
- block.append(ContentText(node.text))
- parent.append(block)
+ val content = ContentText(node.text)
+ if (parent is ContentBlockCode) {
+ parent.append(content)
+ } else {
+ parent.append(ContentBlockCode().apply { append(content) })
+ }
}
MarkdownTokenTypes.TEXT -> {
diff --git a/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt b/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt
index 2b085769..ffef399d 100644
--- a/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt
+++ b/core/src/main/kotlin/Kotlin/DeclarationLinkResolver.kt
@@ -1,16 +1,21 @@
package org.jetbrains.dokka
import com.google.inject.Inject
+import org.jetbrains.dokka.Model.DescriptorSignatureProvider
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
+import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor
import org.jetbrains.kotlin.idea.kdoc.resolveKDocLink
+import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyPrivateApi
+import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyPublicApi
class DeclarationLinkResolver
@Inject constructor(val resolutionFacade: DokkaResolutionFacade,
val refGraph: NodeRefer