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/Kotlin/DocumentationBuilder.kt | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'core/src/main/kotlin/Kotlin') 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