diff options
author | Martin Bonnin <martin@mbonnin.net> | 2020-11-18 12:48:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-18 12:48:03 +0100 |
commit | 1959b914c0838be814d45f617517ac73fa33cd47 (patch) | |
tree | 899805a421b45625ceffd599520a3f3e3d237e5a /core/src/main/kotlin | |
parent | d6c798e44381fd436a264229f94f19528382c136 (diff) | |
download | dokka-1959b914c0838be814d45f617517ac73fa33cd47.tar.gz dokka-1959b914c0838be814d45f617517ac73fa33cd47.tar.bz2 dokka-1959b914c0838be814d45f617517ac73fa33cd47.zip |
Add matchingRegex (#598)
* add matchingRegex as a simpler replacement for `prefix`
* remove useless check
* added a note about the order of the matchingRegex
Diffstat (limited to 'core/src/main/kotlin')
4 files changed, 6 insertions, 10 deletions
diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt index 584d8b8c..6d6d8698 100644 --- a/core/src/main/kotlin/DokkaBootstrapImpl.kt +++ b/core/src/main/kotlin/DokkaBootstrapImpl.kt @@ -7,11 +7,7 @@ import java.util.function.BiConsumer fun parsePerPackageOptions(args: List<String>): List<PackageOptions> = args.map { it.split(",") }.map { - val prefix = it.first() - if (prefix == "") - throw IllegalArgumentException( - "Please do not register packageOptions with all match pattern, use global settings instead" - ) + val matchingRegex = it.first() val args = it.subList(1, it.size) @@ -28,7 +24,7 @@ fun parsePerPackageOptions(args: List<String>): List<PackageOptions> = args.map ?: DokkaDefaults.suppress PackageOptionsImpl( - prefix, + matchingRegex, includeNonPublic = privateApi, reportUndocumented = reportUndocumented, skipDeprecated = !deprecated, diff --git a/core/src/main/kotlin/configuration.kt b/core/src/main/kotlin/configuration.kt index bc097ae4..15525152 100644 --- a/core/src/main/kotlin/configuration.kt +++ b/core/src/main/kotlin/configuration.kt @@ -144,7 +144,7 @@ interface DokkaConfiguration : Serializable { } interface PackageOptions : Serializable { - val prefix: String + val matchingRegex: String val includeNonPublic: Boolean val reportUndocumented: Boolean? val skipDeprecated: Boolean diff --git a/core/src/main/kotlin/defaultConfiguration.kt b/core/src/main/kotlin/defaultConfiguration.kt index 61c86c5a..240fb110 100644 --- a/core/src/main/kotlin/defaultConfiguration.kt +++ b/core/src/main/kotlin/defaultConfiguration.kt @@ -71,7 +71,7 @@ data class SourceLinkDefinitionImpl( } data class PackageOptionsImpl( - override val prefix: String, + override val matchingRegex: String, override val includeNonPublic: Boolean, override val reportUndocumented: Boolean?, override val skipDeprecated: Boolean, diff --git a/core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt b/core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt index 60769e9b..21548a4c 100644 --- a/core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt +++ b/core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt @@ -28,8 +28,8 @@ fun PreMergeDocumentableTransformer.sourceSet(documentable: Documentable): Dokka fun PreMergeDocumentableTransformer.perPackageOptions(documentable: Documentable): PackageOptions? { val packageName = documentable.dri.packageName ?: return null return sourceSet(documentable).perPackageOptions - .sortedByDescending { packageOptions -> packageOptions.prefix.length } - .firstOrNull { packageOptions -> packageName.startsWith(packageOptions.prefix) } + .sortedByDescending { packageOptions -> packageOptions.matchingRegex.length } + .firstOrNull { packageOptions -> Regex(packageOptions.matchingRegex).matches(packageName) } } fun <T> PreMergeDocumentableTransformer.source(documentable: T) where T : Documentable, T : WithSources = |