Skip to content

Commit

Permalink
Make module name optional in cli (#1850)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinAman committed Apr 29, 2021
1 parent 34be1ad commit 6a6017a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
Expand Up @@ -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")
}
}
10 changes: 8 additions & 2 deletions runners/cli/src/main/kotlin/cli/main.kt
Expand Up @@ -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,
Expand Down Expand Up @@ -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() = ""
Expand Down

0 comments on commit 6a6017a

Please sign in to comment.