aboutsummaryrefslogtreecommitdiff
path: root/dokka-runners/runner-cli/src/test
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2023-11-10 11:46:54 +0100
committerGitHub <noreply@github.com>2023-11-10 11:46:54 +0100
commit8e5c63d035ef44a269b8c43430f43f5c8eebfb63 (patch)
tree1b915207b2b9f61951ddbf0ff2e687efd053d555 /dokka-runners/runner-cli/src/test
parenta44efd4ba0c2e4ab921ff75e0f53fc9335aa79db (diff)
downloaddokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.tar.gz
dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.tar.bz2
dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.zip
Restructure the project to utilize included builds (#3174)
* Refactor and simplify artifact publishing * Update Gradle to 8.4 * Refactor and simplify convention plugins and build scripts Fixes #3132 --------- Co-authored-by: Adam <897017+aSemy@users.noreply.github.com> Co-authored-by: Oleg Yukhnevich <whyoleg@gmail.com>
Diffstat (limited to 'dokka-runners/runner-cli/src/test')
-rw-r--r--dokka-runners/runner-cli/src/test/kotlin/org/jetbrains/dokka/CliTest.kt46
-rw-r--r--dokka-runners/runner-cli/src/test/resources/my-file-no-sourceset-options.json13
-rw-r--r--dokka-runners/runner-cli/src/test/resources/my-file.json51
3 files changed, 110 insertions, 0 deletions
diff --git a/dokka-runners/runner-cli/src/test/kotlin/org/jetbrains/dokka/CliTest.kt b/dokka-runners/runner-cli/src/test/kotlin/org/jetbrains/dokka/CliTest.kt
new file mode 100644
index 00000000..48441e4c
--- /dev/null
+++ b/dokka-runners/runner-cli/src/test/kotlin/org/jetbrains/dokka/CliTest.kt
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ */
+
+package org.jetbrains.dokka
+
+import java.nio.file.Paths
+import kotlin.test.Test
+import kotlin.test.assertEquals
+import kotlin.test.assertTrue
+
+class CliIntegrationTest {
+
+ @Test
+ fun `should apply global settings to all source sets`() {
+ val jsonPath = Paths.get(javaClass.getResource("/my-file.json")?.toURI() ?: throw IllegalStateException("No JSON found!")).toFile().toString()
+ val globalArguments = GlobalArguments(arrayOf(jsonPath))
+
+ val configuration = initializeConfiguration(globalArguments)
+
+ configuration.sourceSets.forEach {
+ assertTrue(it.perPackageOptions.isNotEmpty())
+ assertTrue(it.sourceLinks.isNotEmpty())
+ assertTrue(it.externalDocumentationLinks.isNotEmpty())
+
+ assertTrue(it.externalDocumentationLinks.any { it.url.toString() == "https://docs.oracle.com/javase/8/docs/api/" })
+ assertEquals(it.sourceLinks.single().localDirectory, "/home/Vadim.Mishenev/dokka/examples/cli/src/main/kotlin")
+ assertEquals(it.perPackageOptions.single().matchingRegex, "my-custom-regex")
+ }
+
+ }
+
+ @Test
+ fun `should not fail when no sourceset options are specified`() {
+ val jsonPath = Paths.get(javaClass.getResource("/my-file-no-sourceset-options.json")?.toURI() ?: throw IllegalStateException("No JSON found!")).toFile().toString()
+ val globalArguments = GlobalArguments(arrayOf(jsonPath))
+
+ val configuration = initializeConfiguration(globalArguments)
+
+ configuration.sourceSets.forEach {
+ assertTrue(it.perPackageOptions.isEmpty())
+ assertTrue(it.sourceLinks.isEmpty())
+ assertTrue(it.externalDocumentationLinks.size == 2) // there are default values, java and kotlin stdlibs
+ }
+ }
+}
diff --git a/dokka-runners/runner-cli/src/test/resources/my-file-no-sourceset-options.json b/dokka-runners/runner-cli/src/test/resources/my-file-no-sourceset-options.json
new file mode 100644
index 00000000..3a8643d1
--- /dev/null
+++ b/dokka-runners/runner-cli/src/test/resources/my-file-no-sourceset-options.json
@@ -0,0 +1,13 @@
+{
+ "outputDir": "build/docs",
+ "sourceSets": [
+ {
+ "moduleDisplayName": "Sample",
+ "sourceSetID": {
+ "scopeId": "sample",
+ "sourceSetName": "main"
+ },
+ "sourceRoots": ["sample"]
+ }
+ ]
+}
diff --git a/dokka-runners/runner-cli/src/test/resources/my-file.json b/dokka-runners/runner-cli/src/test/resources/my-file.json
new file mode 100644
index 00000000..49dda814
--- /dev/null
+++ b/dokka-runners/runner-cli/src/test/resources/my-file.json
@@ -0,0 +1,51 @@
+{
+ "moduleName": "Dokka Example",
+ "moduleVersion": null,
+ "outputDir": "$outputPath",
+ "pluginsClasspath": ["$pluginsClasspath"],
+ "cacheRoot": null,
+ "offlineMode": false,
+ "sourceLinks": [{
+ "localDirectory": "/home/Vadim.Mishenev/dokka/examples/cli/src/main/kotlin",
+ "remoteUrl": "https://github.com/Kotlin/dokka/tree/master/examples/gradle/dokka-gradle-example/src/main/kotlin",
+ "remoteLineSuffix": "#L"
+ }],
+ "externalDocumentationLinks": [{
+ "url": "https://docs.oracle.com/javase/8/docs/api/",
+ "packageListUrl": "https://docs.oracle.com/javase/8/docs/api/package-list"
+ }],
+ "perPackageOptions": [{
+ "matchingRegex": "my-custom-regex",
+ "skipDeprecated": "true",
+ "reportUndocumented": "true",
+ "includeNonPublic": "true",
+ "documentedVisibilities": ["PUBLIC", "PRIVATE", "PROTECTED", "INTERNAL", "PACKAGE"]
+ }],
+ "sourceSets": [
+ {
+ "displayName": "jvm",
+ "sourceSetID": {
+ "scopeId": ":dokkaHtml",
+ "sourceSetName": "main"
+ },
+ "sourceRoots": [
+ "$projectPath"
+ ],
+ "dependentSourceSets": [],
+ "samples": [],
+ "includes": [],
+ "includeNonPublic": false,
+ "reportUndocumented": false,
+ "skipEmptyPackages": true,
+ "skipDeprecated": false,
+ "jdkVersion": 8,
+ "sourceLinks": [],
+ "perPackageOptions": [],
+ "externalDocumentationLinks": [],
+ "noStdlibLink": false,
+ "noJdkLink": false,
+ "suppressedFiles": [],
+ "analysisPlatform": "jvm"
+ }
+ ]
+}