aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2021-04-29 19:31:57 +0200
committerGitHub <noreply@github.com>2021-04-29 19:31:57 +0200
commit6a6017aec8bb502c674b988acb8b993774dd137a (patch)
treeec70f1977910b45231bd735d0399b0cd66273beb
parent34be1adfc7a5a40cf649b0243eefae8b03af49e1 (diff)
downloaddokka-6a6017aec8bb502c674b988acb8b993774dd137a.tar.gz
dokka-6a6017aec8bb502c674b988acb8b993774dd137a.tar.bz2
dokka-6a6017aec8bb502c674b988acb8b993774dd137a.zip
Make module name optional in cli (#1850)
-rw-r--r--integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/CliIntegrationTest.kt34
-rw-r--r--runners/cli/src/main/kotlin/cli/main.kt10
2 files changed, 42 insertions, 2 deletions
diff --git a/integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/CliIntegrationTest.kt b/integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/CliIntegrationTest.kt
index 8fdcaad5..05ef667a 100644
--- a/integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/CliIntegrationTest.kt
+++ b/integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/CliIntegrationTest.kt
@@ -147,4 +147,38 @@ class CliIntegrationTest : AbstractCliIntegrationTest() {
"Expected to render empty packages"
)
}
+
+ @Test
+ fun `module name should be optional`() {
+ val dokkaOutputDir = File(projectDir, "output")
+ assertTrue(dokkaOutputDir.mkdirs())
+ val process = ProcessBuilder(
+ "java", "-jar", cliJarFile.path,
+ "-outputDir", dokkaOutputDir.path,
+ "-pluginsClasspath", basePluginJarFile.path,
+ "-sourceSet",
+ buildString {
+ append(" -src ${File(projectDir, "src").path}")
+ }
+ )
+ .redirectErrorStream(true)
+ .start()
+
+ val result = process.awaitProcessResult()
+ assertEquals(0, result.exitCode, "Expected exitCode 0 (Success)")
+
+ assertTrue(dokkaOutputDir.isDirectory, "Missing dokka output directory")
+
+ val imagesDir = File(dokkaOutputDir, "images")
+ assertTrue(imagesDir.isDirectory, "Missing images directory")
+
+ val scriptsDir = File(dokkaOutputDir, "scripts")
+ assertTrue(scriptsDir.isDirectory, "Missing scripts directory")
+
+ val stylesDir = File(dokkaOutputDir, "styles")
+ assertTrue(stylesDir.isDirectory, "Missing styles directory")
+
+ val navigationHtml = File(dokkaOutputDir, "navigation.html")
+ assertTrue(navigationHtml.isFile, "Missing navigation.html")
+ }
}
diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt
index 7c402df5..36edb2d9 100644
--- a/runners/cli/src/main/kotlin/cli/main.kt
+++ b/runners/cli/src/main/kotlin/cli/main.kt
@@ -74,7 +74,7 @@ class GlobalArguments(args: Array<String>) : DokkaConfiguration {
description = "Document generated or obvious functions like default `toString` or `equals`"
).default(!DokkaDefaults.suppressObviousFunctions)
- override val suppressObviousFunctions: Boolean by lazy{ !noSuppressObviousFunctions }
+ override val suppressObviousFunctions: Boolean by lazy { !noSuppressObviousFunctions }
private val _includes by parser.option(
ArgTypeFile,
@@ -316,7 +316,13 @@ object ArgTypeSourceLinkDefinition : ArgType<DokkaConfiguration.SourceLinkDefini
data class ArgTypeArgument(val moduleName: CLIEntity<kotlin.String>) :
ArgType<DokkaConfiguration.DokkaSourceSet>(true) {
override fun convert(value: kotlin.String, name: kotlin.String): DokkaConfiguration.DokkaSourceSet =
- parseSourceSet(moduleName.value, value.split(" ").filter { it.isNotBlank() }.toTypedArray())
+ (if (moduleName.valueOrigin != ArgParser.ValueOrigin.UNSET && moduleName.valueOrigin != ArgParser.ValueOrigin.UNDEFINED) {
+ moduleName.value
+ } else {
+ DokkaDefaults.moduleName
+ }).let { moduleNameOrDefault ->
+ parseSourceSet(moduleNameOrDefault, value.split(" ").filter { it.isNotBlank() }.toTypedArray())
+ }
override val description: kotlin.String
get() = ""