aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2021-02-24 16:17:45 +0100
committerGitHub <noreply@github.com>2021-02-24 16:17:45 +0100
commitcbbc62ff5e1c406037ba5a6e5c9b81f3b53d2700 (patch)
tree37cf26f8b257c7b6e5b3d0178778e19330e061f1
parente07f411dc3c2e99acf18dfa428546804b80d30f9 (diff)
downloaddokka-cbbc62ff5e1c406037ba5a6e5c9b81f3b53d2700.tar.gz
dokka-cbbc62ff5e1c406037ba5a6e5c9b81f3b53d2700.tar.bz2
dokka-cbbc62ff5e1c406037ba5a6e5c9b81f3b53d2700.zip
Fix parameters on cli and bump kotlinx.cli (#1755)
-rw-r--r--docs/src/doc/docs/user_guide/cli/usage.md2
-rw-r--r--integration-tests/cli/projects/it-cli/src/main/kotlin/it/basic/EmptyPackage.kt1
-rw-r--r--integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/CliIntegrationTest.kt68
-rw-r--r--runners/cli/build.gradle.kts2
-rw-r--r--runners/cli/src/main/kotlin/cli/main.kt12
5 files changed, 74 insertions, 11 deletions
diff --git a/docs/src/doc/docs/user_guide/cli/usage.md b/docs/src/doc/docs/user_guide/cli/usage.md
index 1f6b1124..e77c686e 100644
--- a/docs/src/doc/docs/user_guide/cli/usage.md
+++ b/docs/src/doc/docs/user_guide/cli/usage.md
@@ -30,7 +30,7 @@ Dokka supports the following command line arguments:
* `-includeNonPublic` - include protected and private code
* `-skipDeprecated` - if set, deprecated elements are not included in the generated documentation
* `-reportUndocumented` - warn about undocumented members
- * `-skipEmptyPackages` - do not create index pages for empty packages
+ * `-noSkipEmptyPackages` - create index pages for empty packages
* `-packageOptions` - list of package options in format `matchingRegex,-deprecated,-privateApi,+reportUndocumented;matchingRegex, ...`, separated by `;`
* `-links` - list of external documentation links in format `url^packageListUrl^^url2...`, separated by `;`
* `-srcLink` - mapping between a source directory and a Web site for browsing the code in format `<path>=<url>[#lineSuffix]`
diff --git a/integration-tests/cli/projects/it-cli/src/main/kotlin/it/basic/EmptyPackage.kt b/integration-tests/cli/projects/it-cli/src/main/kotlin/it/basic/EmptyPackage.kt
new file mode 100644
index 00000000..50f02c00
--- /dev/null
+++ b/integration-tests/cli/projects/it-cli/src/main/kotlin/it/basic/EmptyPackage.kt
@@ -0,0 +1 @@
+package emptypackagetest \ No newline at end of file
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 aabc30c1..8fdcaad5 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
@@ -2,10 +2,7 @@ package org.jetbrains.dokka.it.cli
import org.jetbrains.dokka.it.awaitProcessResult
import java.io.File
-import kotlin.test.BeforeTest
-import kotlin.test.Test
-import kotlin.test.assertEquals
-import kotlin.test.assertTrue
+import kotlin.test.*
class CliIntegrationTest : AbstractCliIntegrationTest() {
@@ -86,5 +83,68 @@ class CliIntegrationTest : AbstractCliIntegrationTest() {
assertNoEmptyLinks(file)
assertNoEmptySpans(file)
}
+
+ assertFalse(
+ projectDir.resolve("output").resolve("index.html").readText().contains("emptypackagetest"),
+ "Expected not to render empty packages"
+ )
+ }
+
+ @Test
+ fun failCli() {
+ val dokkaOutputDir = File(projectDir, "output")
+ assertTrue(dokkaOutputDir.mkdirs())
+ val process = ProcessBuilder(
+ "java", "-jar", cliJarFile.path,
+ "-outputDir", dokkaOutputDir.path,
+ "-pluginsClasspath", basePluginJarFile.path,
+ "-moduleName", "Basic Project",
+ "-failOnWarning",
+ "-sourceSet",
+ buildString {
+ append(" -sourceSetName cliMain")
+ append(" -src ${File(projectDir, "src").path}")
+ append(" -jdkVersion 8")
+ append(" -analysisPlatform jvm")
+ append(" -reportUndocumented")
+ }
+ )
+ .redirectErrorStream(true)
+ .start()
+
+ val result = process.awaitProcessResult()
+ assertEquals(1, result.exitCode, "Expected exitCode 1 (Fail)")
+
+ assertTrue(result.output.contains("Exception in thread \"main\" org.jetbrains.dokka.DokkaException: Failed with warningCount"))
+ }
+
+ @Test
+ fun emptyPackagesTest() {
+ val dokkaOutputDir = File(projectDir, "output")
+ assertTrue(dokkaOutputDir.mkdirs())
+ val process = ProcessBuilder(
+ "java", "-jar", cliJarFile.path,
+ "-outputDir", dokkaOutputDir.path,
+ "-pluginsClasspath", basePluginJarFile.path,
+ "-moduleName", "Basic Project",
+ "-sourceSet",
+ buildString {
+ append(" -sourceSetName cliMain")
+ append(" -src ${File(projectDir, "src").path}")
+ append(" -jdkVersion 8")
+ append(" -analysisPlatform jvm")
+ append(" -noSkipEmptyPackages")
+ }
+ )
+ .redirectErrorStream(true)
+ .start()
+
+ val result = process.awaitProcessResult()
+ assertEquals(0, result.exitCode, "Expected exitCode 0 (Success)")
+
+ assertTrue(
+ projectDir.resolve("output").resolve("index.html").readText().contains("emptypackagetest"),
+ "Expected to render empty packages"
+ )
}
}
diff --git a/runners/cli/build.gradle.kts b/runners/cli/build.gradle.kts
index 4ad34192..5d07ef76 100644
--- a/runners/cli/build.gradle.kts
+++ b/runners/cli/build.gradle.kts
@@ -11,7 +11,7 @@ repositories {
}
dependencies {
- implementation("org.jetbrains.kotlinx:kotlinx-cli-jvm:0.2.1")
+ implementation("org.jetbrains.kotlinx:kotlinx-cli-jvm:0.3.1")
implementation(project(":core"))
implementation(kotlin("stdlib"))
}
diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt
index 290950ec..1597ed56 100644
--- a/runners/cli/src/main/kotlin/cli/main.kt
+++ b/runners/cli/src/main/kotlin/cli/main.kt
@@ -56,12 +56,12 @@ class GlobalArguments(args: Array<String>) : DokkaConfiguration {
override val offlineMode by parser.option(
ArgType.Boolean,
- "Offline mode (do not download package lists from the Internet)"
+ description = "Offline mode (do not download package lists from the Internet)"
).default(DokkaDefaults.offlineMode)
override val failOnWarning by parser.option(
ArgType.Boolean,
- "Throw an exception if the generation exited with warnings"
+ description = "Throw an exception if the generation exited with warnings"
).default(DokkaDefaults.failOnWarning)
override val delayTemplateSubstitution by parser.option(
@@ -166,10 +166,12 @@ private fun parseSourceSet(moduleName: String, args: Array<String>): DokkaConfig
val reportUndocumented by parser.option(ArgType.Boolean, description = "Report undocumented members")
.default(DokkaDefaults.reportUndocumented)
- val skipEmptyPackages by parser.option(
+ val noSkipEmptyPackages by parser.option(
ArgType.Boolean,
- description = "Do not create index pages for empty packages"
- ).default(DokkaDefaults.skipEmptyPackages)
+ description = "Create index pages for empty packages"
+ ).default(!DokkaDefaults.skipEmptyPackages)
+
+ val skipEmptyPackages by lazy { !noSkipEmptyPackages }
val skipDeprecated by parser.option(ArgType.Boolean, description = "Do not output deprecated members")
.default(DokkaDefaults.skipDeprecated)