From 3b6e3a8bf69b7470cd7e9a867ff3b2e7e645fbd4 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Wed, 3 May 2017 16:25:50 +0300 Subject: Add bunch of new parameters to runners Such as packageOptions, impliedPlatforms and so on --- core/src/main/kotlin/DokkaBootstrapImpl.kt | 7 +++++-- core/src/main/kotlin/Generation/DokkaGenerator.kt | 4 ++-- core/src/main/kotlin/Generation/configurationImpl.kt | 11 +++++++++-- core/src/main/kotlin/Kotlin/DocumentationBuilder.kt | 19 +++++++++---------- 4 files changed, 25 insertions(+), 16 deletions(-) (limited to 'core/src') diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt index fafa5daa..5ac1c57f 100644 --- a/core/src/main/kotlin/DokkaBootstrapImpl.kt +++ b/core/src/main/kotlin/DokkaBootstrapImpl.kt @@ -1,5 +1,6 @@ package org.jetbrains.dokka +import org.jetbrains.dokka.DokkaConfiguration.PackageOptions import ru.yole.jkid.deserialization.deserialize import java.util.function.BiConsumer @@ -15,7 +16,7 @@ fun parsePerPackageOptions(arg: String): List { 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 - PackageOptions(prefix, includeNonPublic = privateApi, reportUndocumented = reportUndocumented, skipDeprecated = !deprecated) + PackageOptionsImpl(prefix, includeNonPublic = privateApi, reportUndocumented = reportUndocumented, skipDeprecated = !deprecated) } } @@ -58,7 +59,9 @@ class DokkaBootstrapImpl : DokkaBootstrap { skipDeprecated, jdkVersion, generateIndexPages, - sourceLinks + sourceLinks, + impliedPlatforms, + perPackageOptions ) ) } diff --git a/core/src/main/kotlin/Generation/DokkaGenerator.kt b/core/src/main/kotlin/Generation/DokkaGenerator.kt index 67c641a0..3350ab1d 100644 --- a/core/src/main/kotlin/Generation/DokkaGenerator.kt +++ b/core/src/main/kotlin/Generation/DokkaGenerator.kt @@ -35,7 +35,7 @@ class DokkaGenerator(val logger: DokkaLogger, private val documentationModule = DocumentationModule(moduleName) fun generate() { - val sourcesGroupedByPlatform = sources.groupBy { it.defaultPlatforms.firstOrNull() } + val sourcesGroupedByPlatform = sources.groupBy { it.platforms.firstOrNull() } for ((platform, roots) in sourcesGroupedByPlatform) { appendSourceModule(platform, roots) } @@ -67,7 +67,7 @@ class DokkaGenerator(val logger: DokkaLogger, val containingFilePath = descriptor.sourcePsi()?.containingFile?.virtualFile?.canonicalPath ?.let { File(it).absolutePath } val sourceRoot = containingFilePath?.let { path -> sourceRoots.find { path.startsWith(it.path) } } - return sourceRoot?.defaultPlatforms ?: defaultPlatformAsList + return sourceRoot?.platforms ?: defaultPlatformAsList } } diff --git a/core/src/main/kotlin/Generation/configurationImpl.kt b/core/src/main/kotlin/Generation/configurationImpl.kt index 6ed0d639..bb2f6d12 100644 --- a/core/src/main/kotlin/Generation/configurationImpl.kt +++ b/core/src/main/kotlin/Generation/configurationImpl.kt @@ -18,7 +18,7 @@ data class SourceLinkDefinitionImpl(override val path: String, } } -class SourceRootImpl(path: String, override val defaultPlatforms: List = emptyList()) : SourceRoot { +class SourceRootImpl(path: String, override val platforms: List = emptyList()) : SourceRoot { override val path: String = File(path).absolutePath companion object { @@ -29,6 +29,11 @@ class SourceRootImpl(path: String, override val defaultPlatforms: List = } } +data class PackageOptionsImpl(override val prefix: String, + override val includeNonPublic: Boolean = false, + override val reportUndocumented: Boolean = true, + override val skipDeprecated: Boolean = false) : DokkaConfiguration.PackageOptions + data class DokkaConfigurationImpl(override val moduleName: String, override val classpath: List, override val sourceRoots: List, @@ -43,4 +48,6 @@ data class DokkaConfigurationImpl(override val moduleName: String, override val skipDeprecated: Boolean, override val jdkVersion: Int, override val generateIndexPages: Boolean, - override val sourceLinks: List) : DokkaConfiguration \ No newline at end of file + override val sourceLinks: List, + override val impliedPlatforms: List, + override val perPackageOptions: List) : DokkaConfiguration \ No newline at end of file diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt index aa4eed24..b034a299 100644 --- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt +++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt @@ -3,6 +3,7 @@ package org.jetbrains.dokka import com.google.inject.Inject import com.intellij.openapi.util.text.StringUtil import com.intellij.psi.PsiJavaFile +import org.jetbrains.dokka.DokkaConfiguration.PackageOptions import org.jetbrains.dokka.DokkaConfiguration.SourceLinkDefinition import org.jetbrains.dokka.Kotlin.DescriptorDocumentationParser import org.jetbrains.kotlin.builtins.KotlinBuiltIns @@ -44,21 +45,19 @@ class DocumentationOptions(val outputDir: String, val impliedPlatforms: List = emptyList(), // Sorted by pattern length perPackageOptions: List = emptyList()) { - val perPackageOptions = perPackageOptions.sortedByDescending { it.prefix.length } + PackageOptions("", includeNonPublic, reportUndocumented, skipDeprecated) + init { + if (perPackageOptions.any { it.prefix == "" }) + throw IllegalArgumentException("Please do not register packageOptions with all match pattern, use global settings instead") + } + + val perPackageOptions = perPackageOptions.sortedByDescending { it.prefix.length } + val rootPackageOptions = PackageOptionsImpl("", includeNonPublic, reportUndocumented, skipDeprecated) - fun effectivePackageOptions(pack: String): PackageOptions = perPackageOptions.first { pack.startsWith(it.prefix) } + fun effectivePackageOptions(pack: String): PackageOptions = perPackageOptions.firstOrNull { pack.startsWith(it.prefix + ".") } ?: rootPackageOptions fun effectivePackageOptions(pack: FqName): PackageOptions = effectivePackageOptions(pack.asString()) } - -data class PackageOptions(val prefix: String, - val includeNonPublic: Boolean = false, - val reportUndocumented: Boolean = true, - val skipDeprecated: Boolean = false) - - - private fun isExtensionForExternalClass(extensionFunctionDescriptor: DeclarationDescriptor, extensionReceiverDescriptor: DeclarationDescriptor, allFqNames: Collection): Boolean { -- cgit