From bfd615dde13ef6ebbfaca6b042f263a57c11018c Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 24 Feb 2017 11:33:17 +0100 Subject: Option to skip declarations in root package from generated documentation (they can't be imported anyway) --- core/src/main/kotlin/DokkaBootstrapImpl.kt | 2 ++ core/src/main/kotlin/Generation/DokkaGenerator.kt | 8 +++++--- core/src/main/kotlin/Kotlin/DocumentationBuilder.kt | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'core/src/main') diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt index 5f3fc7b3..8038089f 100644 --- a/core/src/main/kotlin/DokkaBootstrapImpl.kt +++ b/core/src/main/kotlin/DokkaBootstrapImpl.kt @@ -42,6 +42,7 @@ class DokkaBootstrapImpl : DokkaBootstrap { outputDir: String, format: String, includeNonPublic: Boolean, + includeRootPackage: Boolean, reportUndocumented: Boolean, skipEmptyPackages: Boolean, skipDeprecated: Boolean, @@ -59,6 +60,7 @@ class DokkaBootstrapImpl : DokkaBootstrap { outputDir, format, includeNonPublic, + includeRootPackage, reportUndocumented, skipEmptyPackages, skipDeprecated, diff --git a/core/src/main/kotlin/Generation/DokkaGenerator.kt b/core/src/main/kotlin/Generation/DokkaGenerator.kt index 2c1cdb03..b7163a5c 100644 --- a/core/src/main/kotlin/Generation/DokkaGenerator.kt +++ b/core/src/main/kotlin/Generation/DokkaGenerator.kt @@ -148,9 +148,11 @@ fun buildDocumentationModule(injector: Injector, for (include in includes) { packageDocs.parse(include, fragments.firstOrNull()) } - documentationModule.updateContent { - for (node in packageDocs.moduleContent.children) { - append(node) + if (documentationModule.content.isEmpty()) { + documentationModule.updateContent { + for (node in packageDocs.moduleContent.children) { + append(node) + } } } diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt index 10b5c598..4974b765 100644 --- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt +++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt @@ -33,6 +33,7 @@ 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, @@ -337,6 +338,7 @@ class DocumentationBuilder val allFqNames = fragments.map { it.fqName }.distinct() for (packageName in allFqNames) { + if (packageName.isRoot && !options.includeRootPackage) continue val declarations = fragments.filter { it.fqName == packageName }.flatMap { it.getMemberScope().getContributedDescriptors() } if (options.skipEmptyPackages && declarations.none { it.isDocumented(options) }) continue -- cgit