Skip to content

Commit 7d84045

Browse files
committed
address pr feedback: generate module docs for testing
1 parent e54f6df commit 7d84045

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

dokka-aws/build.gradle.kts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
*/
55
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
66
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
7+
import java.time.LocalDate
78

89
/*
910
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
1011
* SPDX-License-Identifier: Apache-2.0
1112
*/
1213
plugins {
14+
alias(libs.plugins.dokka)
1315
alias(libs.plugins.kotlin.jvm)
1416
}
1517

@@ -40,3 +42,29 @@ tasks.withType<JavaCompile> {
4042
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
4143
targetCompatibility = JavaVersion.VERSION_1_8.toString()
4244
}
45+
46+
tasks.withType<org.jetbrains.dokka.gradle.AbstractDokkaTask>().configureEach {
47+
val sdkVersion: String by project
48+
moduleVersion.set(sdkVersion)
49+
50+
val year = LocalDate.now().year
51+
val pluginConfigMap = mapOf(
52+
"org.jetbrains.dokka.base.DokkaBase" to """
53+
{
54+
"customStyleSheets": [
55+
"${rootProject.file("docs/dokka-presets/css/logo-styles.css")}",
56+
"${rootProject.file("docs/dokka-presets/css/aws-styles.css")}"
57+
],
58+
"customAssets": [
59+
"${rootProject.file("docs/dokka-presets/assets/logo-icon.svg")}",
60+
"${rootProject.file("docs/dokka-presets/assets/aws_logo_white_59x35.png")}",
61+
"${rootProject.file("docs/dokka-presets/scripts/accessibility.js")}"
62+
],
63+
"footerMessage": "© $year, Amazon Web Services, Inc. or its affiliates. All rights reserved.",
64+
"separateInheritedMembers" : true,
65+
"templatesDir": "${rootProject.file("docs/dokka-presets/templates")}"
66+
}
67+
""",
68+
)
69+
pluginsMapConfiguration.set(pluginConfigMap)
70+
}

dokka-aws/src/test/kotlin/aws/sdk/kotlin/dokka/DokkaAwsTest.kt

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,47 @@
55
package aws.sdk.kotlin.dokka
66

77
import org.jsoup.Jsoup
8+
import org.junit.jupiter.api.AfterEach
89
import org.junit.jupiter.api.Assumptions.assumeTrue
10+
import org.junit.jupiter.api.BeforeEach
911
import org.junit.jupiter.api.Test
1012
import java.io.File
1113
import kotlin.test.assertTrue
1214

1315
class DokkaAwsTest {
16+
val dokkaOutputDir = File("build/dokka")
17+
18+
@BeforeEach
19+
fun generateDocs() {
20+
val process = ProcessBuilder(
21+
"./gradlew",
22+
":dokka-aws:dokkaHtml"
23+
).directory(File(".."))
24+
.redirectErrorStream(true)
25+
.start()
26+
27+
val exitCode = process.waitFor()
28+
assumeTrue(
29+
exitCode == 0,
30+
"Dokka generation failed with exit code $exitCode"
31+
)
32+
}
33+
34+
@AfterEach
35+
fun cleanup() {
36+
if (dokkaOutputDir.exists()) {
37+
try {
38+
dokkaOutputDir.deleteRecursively()
39+
println("Successfully deleted dokka folder")
40+
} catch (e: Exception) {
41+
println("Failed to delete dokka folder: ${e.message}")
42+
}
43+
}
44+
}
45+
1446
@Test
1547
fun testLoadScripts() {
16-
val testFile = File("../build/dokka/htmlMultiModule/index.html")
48+
val testFile = File("build/dokka/html/index.html")
1749

1850
assumeTrue(
1951
testFile.exists(),

0 commit comments

Comments
 (0)