Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make module name optional in cli #1850

Merged
merged 1 commit into from
Apr 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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