From 37d12bed40edc226d96d0e1a4b28a24583ece94f Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Wed, 22 Jul 2020 11:12:16 +0200 Subject: DokkaConfiguration: Use `Set` instead of `List` when collections are expected to be distinct --- runners/cli/src/main/kotlin/cli/main.kt | 40 ++++++++++++++++----------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'runners/cli/src') diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt index df763596..a9c15ec1 100644 --- a/runners/cli/src/main/kotlin/cli/main.kt +++ b/runners/cli/src/main/kotlin/cli/main.kt @@ -36,11 +36,13 @@ class GlobalArguments(args: Array) : DokkaConfiguration { description = "Configuration for plugins in format fqPluginName=json^^fqPluginName=json..." ).default(emptyMap()) - override val pluginsClasspath by parser.option( + private val pluginsClasspathList by parser.option( ArgTypeFile, + fullName = "pluginsClasspath", description = "List of jars with dokka plugins (allows many paths separated by the semicolon `;`)" ).delimiter(";") + override val pluginsClasspath: Set by lazy { pluginsClasspathList.toMutableSet() } override val offlineMode by parser.option( ArgType.Boolean, @@ -77,19 +79,19 @@ class GlobalArguments(args: Array) : DokkaConfiguration { init { parser.parse(args) - sourceSets.all { + sourceSets.forEach { it.perPackageOptions.cast>() .addAll(parsePerPackageOptions(globalPackageOptions)) } - sourceSets.all { - it.externalDocumentationLinks.cast>().addAll(parseLinks(globalLinks)) + sourceSets.forEach { + it.externalDocumentationLinks.cast>().addAll(parseLinks(globalLinks)) } globalSrcLink.forEach { if (it.isNotEmpty() && it.contains("=")) sourceSets.all { sourceSet -> - sourceSet.sourceLinks.cast>() + sourceSet.sourceLinks.cast>() .add(SourceLinkDefinitionImpl.parseSourceLinkDefinition(it)) } else { @@ -98,10 +100,7 @@ class GlobalArguments(args: Array) : DokkaConfiguration { } sourceSets.forEach { - it.externalDocumentationLinks.cast>().addAll(defaultLinks(it)) - it.externalDocumentationLinks.cast>().replaceAll { link -> - ExternalDocumentationLink.Builder(link.url, link.packageListUrl).build() - } + it.externalDocumentationLinks.cast>().addAll(defaultLinks(it)) } } } @@ -227,28 +226,28 @@ private fun parseSourceSet(args: Array): DokkaConfiguration.DokkaSourceS override val moduleDisplayName = moduleDisplayName ?: moduleName override val displayName = displayName override val sourceSetID = DokkaSourceSetID(moduleName, sourceSetName) - override val classpath = classpath - override val sourceRoots = sourceRoots.map { SourceRootImpl(it) } - override val dependentSourceSets: Set = dependentSourceSets + override val classpath = classpath.toMutableSet() + override val sourceRoots = sourceRoots.toMutableSet() + override val dependentSourceSets = dependentSourceSets .map { dependentSourceSetName -> dependentSourceSetName.split('/').let { DokkaSourceSetID(it[0], it[1]) } } - .toSet() - override val samples = samples - override val includes = includes + .toMutableSet() + override val samples = samples.toMutableSet() + override val includes = includes.toMutableSet() override val includeNonPublic = includeNonPublic override val includeRootPackage = includeRootPackage override val reportUndocumented = reportUndocumented override val skipEmptyPackages = skipEmptyPackages override val skipDeprecated = skipDeprecated override val jdkVersion = jdkVersion - override val sourceLinks = sourceLinks + override val sourceLinks = sourceLinks.toMutableSet() override val analysisPlatform = analysisPlatform override val perPackageOptions = parsePerPackageOptions(perPackageOptions) - override val externalDocumentationLinks = parseLinks(externalDocumentationLinks) + override val externalDocumentationLinks = parseLinks(externalDocumentationLinks).toMutableSet() override val languageVersion = languageVersion override val apiVersion = apiVersion override val noStdlibLink = noStdlibLink override val noJdkLink = noJdkLink - override val suppressedFiles = suppressedFiles + override val suppressedFiles = suppressedFiles.toMutableSet() } } @@ -307,13 +306,14 @@ object ArgTypeHelpSourceSet : ArgType(false) { fun defaultLinks(config: DokkaConfiguration.DokkaSourceSet): MutableList = mutableListOf().apply { if (!config.noJdkLink) { + // TODO NOW: Duplication val javadocLink = if (config.jdkVersion < 11) "https://docs.oracle.com/javase/${config.jdkVersion}/docs/api/" else "https://docs.oracle.com/en/java/javase/${config.jdkVersion}/docs/api/java.base/" val packageListLink = if (config.jdkVersion < 11) "${javadocLink}/package-list" else "https://docs.oracle.com/en/java/javase/${config.jdkVersion}/docs/api/element-list" - this += DokkaConfiguration.ExternalDocumentationLink + this += ExternalDocumentationLink .Builder(javadocLink, packageListLink) .build() } @@ -324,7 +324,6 @@ fun defaultLinks(config: DokkaConfiguration.DokkaSourceSet): MutableList): List { val (parsedLinks, parsedOfflineLinks) = links @@ -355,3 +354,4 @@ fun main(args: Array) { globalArguments DokkaGenerator(configuration, DokkaConsoleLogger).generate() } + -- cgit