diff options
author | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2017-03-23 22:59:08 +0300 |
---|---|---|
committer | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2017-03-29 18:37:38 +0300 |
commit | 57e38932b414e7496678b3cc1f171cbf7c4d8fbb (patch) | |
tree | 4658b36056734ceda19be3ce78c62791712aef32 /core/src/main/kotlin/Kotlin | |
parent | 921192e64c7f1df02692c1ec7f24f4a8bc9b7231 (diff) | |
download | dokka-57e38932b414e7496678b3cc1f171cbf7c4d8fbb.tar.gz dokka-57e38932b414e7496678b3cc1f171cbf7c4d8fbb.tar.bz2 dokka-57e38932b414e7496678b3cc1f171cbf7c4d8fbb.zip |
Per package options
Diffstat (limited to 'core/src/main/kotlin/Kotlin')
-rw-r--r-- | core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt | 3 | ||||
-rw-r--r-- | core/src/main/kotlin/Kotlin/DocumentationBuilder.kt | 42 |
2 files changed, 31 insertions, 14 deletions
diff --git a/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt b/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt index 6d7ff7ba..dd96bafa 100644 --- a/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt +++ b/core/src/main/kotlin/Kotlin/DescriptorDocumentationParser.kt @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.annotations.argumentValue import org.jetbrains.kotlin.resolve.constants.StringValue +import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.getDescriptorsFiltered import org.jetbrains.kotlin.resolve.source.PsiSourceElement @@ -40,7 +41,7 @@ class DescriptorDocumentationParser val kdoc = descriptor.findKDoc() ?: findStdlibKDoc(descriptor) if (kdoc == null) { - if (options.reportUndocumented && !descriptor.isDeprecated() && + if (options.effectivePackageOptions(descriptor.fqNameSafe).reportUndocumented && !descriptor.isDeprecated() && descriptor !is ValueParameterDescriptor && descriptor !is TypeParameterDescriptor && descriptor !is PropertyAccessorDescriptor && !descriptor.isSuppressWarning()) { logger.warn("No documentation for ${descriptor.signatureWithSourceLocation()}") diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt index 299ad477..7c4e4531 100644 --- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt +++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt @@ -30,17 +30,33 @@ import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf import org.jetbrains.kotlin.types.typeUtil.supertypes import com.google.inject.name.Named as GuiceNamed -data class DocumentationOptions(val outputDir: String, - val outputFormat: String, - val includeNonPublic: Boolean = false, - val includeRootPackage: Boolean = false, - val reportUndocumented: Boolean = true, - val skipEmptyPackages: Boolean = true, - val skipDeprecated: Boolean = false, - val jdkVersion: Int = 6, - val generateIndexPages: Boolean = true, - val sourceLinks: List<SourceLinkDefinition> = emptyList(), - val impliedPlatforms: List<String> = emptyList()) +class DocumentationOptions(val outputDir: String, + val outputFormat: String, + includeNonPublic: Boolean = false, + val includeRootPackage: Boolean = false, + reportUndocumented: Boolean = true, + val skipEmptyPackages: Boolean = true, + skipDeprecated: Boolean = false, + val jdkVersion: Int = 6, + val generateIndexPages: Boolean = true, + val sourceLinks: List<SourceLinkDefinition> = emptyList(), + val impliedPlatforms: List<String> = emptyList(), + // Sorted by pattern length + perPackageOptions: List<PackageOptions> = emptyList()) { + val perPackageOptions = perPackageOptions.sortedByDescending { it.prefix.length } + PackageOptions("", includeNonPublic, reportUndocumented, skipDeprecated) + + + fun effectivePackageOptions(pack: String): PackageOptions = perPackageOptions.first { pack.startsWith(it.prefix) } + 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, @@ -748,11 +764,11 @@ class DocumentationBuilder val visibleToDocumentation = setOf(Visibilities.PROTECTED, Visibilities.PUBLIC) fun DeclarationDescriptor.isDocumented(options: DocumentationOptions): Boolean { - return (options.includeNonPublic + return (options.effectivePackageOptions(fqNameSafe).includeNonPublic || this !is MemberDescriptor || this.visibility in visibleToDocumentation) && !isDocumentationSuppressed() && - (!options.skipDeprecated || !isDeprecated()) + (!options.effectivePackageOptions(fqNameSafe).skipDeprecated || !isDeprecated()) } private fun DeclarationDescriptor.isGenerated() = this is CallableMemberDescriptor && kind != CallableMemberDescriptor.Kind.DECLARATION |