From e9f5da45c0fcfec5f7c150229301904d7915e090 Mon Sep 17 00:00:00 2001 From: Marcin Aman Date: Wed, 7 Oct 2020 13:58:46 +0200 Subject: Make logo replaceable #1339 (#1488) --- integration-tests/gradle/build.gradle.kts | 2 ++ .../gradle/projects/it-basic-groovy/build.gradle | 1 - .../gradle/projects/it-basic/build.gradle.kts | 9 +++++++++ .../projects/it-basic/customResources/custom-resource.svg | 3 +++ .../it-basic/customResources/custom-style-to-add.css | 1 + .../projects/it-basic/customResources/logo-styles.css | 3 +++ .../dokka/it/gradle/BasicGradleIntegrationTest.kt | 13 +++++++++++++ .../projects/it-maven/customResources/custom-resource.svg | 3 +++ .../it-maven/customResources/custom-style-to-add.css | 1 + .../projects/it-maven/customResources/logo-styles.css | 3 +++ integration-tests/maven/projects/it-maven/pom.xml | 11 +++++++++++ .../org/jetbrains/dokka/it/maven/MavenIntegrationTest.kt | 15 +++++++++++++++ 12 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 integration-tests/gradle/projects/it-basic/customResources/custom-resource.svg create mode 100644 integration-tests/gradle/projects/it-basic/customResources/custom-style-to-add.css create mode 100644 integration-tests/gradle/projects/it-basic/customResources/logo-styles.css create mode 100644 integration-tests/maven/projects/it-maven/customResources/custom-resource.svg create mode 100644 integration-tests/maven/projects/it-maven/customResources/custom-style-to-add.css create mode 100644 integration-tests/maven/projects/it-maven/customResources/logo-styles.css (limited to 'integration-tests') diff --git a/integration-tests/gradle/build.gradle.kts b/integration-tests/gradle/build.gradle.kts index 3da416bb..8d3e8247 100644 --- a/integration-tests/gradle/build.gradle.kts +++ b/integration-tests/gradle/build.gradle.kts @@ -7,6 +7,8 @@ dependencies { } tasks.integrationTest { + val dokka_version: String by project + environment("DOKKA_VERSION", dokka_version) inputs.dir(file("projects")) dependsOnMavenLocalPublication() } diff --git a/integration-tests/gradle/projects/it-basic-groovy/build.gradle b/integration-tests/gradle/projects/it-basic-groovy/build.gradle index df2e8624..dc469bba 100644 --- a/integration-tests/gradle/projects/it-basic-groovy/build.gradle +++ b/integration-tests/gradle/projects/it-basic-groovy/build.gradle @@ -11,7 +11,6 @@ dependencies { dokkaHtml { outputDirectory = new File(buildDir, "/dokka/customHtml") - pluginsConfiguration.put("pluginA", "configA") failOnWarning = false dokkaSourceSets { customSourceSet { diff --git a/integration-tests/gradle/projects/it-basic/build.gradle.kts b/integration-tests/gradle/projects/it-basic/build.gradle.kts index a155d9d7..6246bf93 100644 --- a/integration-tests/gradle/projects/it-basic/build.gradle.kts +++ b/integration-tests/gradle/projects/it-basic/build.gradle.kts @@ -1,5 +1,7 @@ import org.jetbrains.dokka.gradle.DokkaTask import org.jetbrains.dokka.gradle.kotlinSourceSet +import org.jetbrains.dokka.base.DokkaBase +import org.jetbrains.dokka.base.DokkaBaseConfiguration import java.net.URL plugins { @@ -7,6 +9,12 @@ plugins { id("org.jetbrains.dokka") } +buildscript { + dependencies { + classpath("org.jetbrains.dokka:dokka-base:${System.getenv("DOKKA_VERSION")}") + } +} + version = "1.5-SNAPSHOT" apply(from = "../template.root.gradle.kts") @@ -40,4 +48,5 @@ tasks.withType { kotlinSourceSet(kotlin.sourceSets["test"]) } } + pluginsMapConfiguration.set(mapOf(DokkaBase::class.qualifiedName to """{ "customStyleSheets": ["${file("customResources/logo-styles.css")}", "${file("customResources/custom-style-to-add.css")}"], "customAssets" : ["${file("customResources/custom-resource.svg")}"] }""")) } diff --git a/integration-tests/gradle/projects/it-basic/customResources/custom-resource.svg b/integration-tests/gradle/projects/it-basic/customResources/custom-resource.svg new file mode 100644 index 00000000..1865f739 --- /dev/null +++ b/integration-tests/gradle/projects/it-basic/customResources/custom-resource.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/integration-tests/gradle/projects/it-basic/customResources/custom-style-to-add.css b/integration-tests/gradle/projects/it-basic/customResources/custom-style-to-add.css new file mode 100644 index 00000000..408c210e --- /dev/null +++ b/integration-tests/gradle/projects/it-basic/customResources/custom-style-to-add.css @@ -0,0 +1 @@ +/* custom stylesheet */ \ No newline at end of file diff --git a/integration-tests/gradle/projects/it-basic/customResources/logo-styles.css b/integration-tests/gradle/projects/it-basic/customResources/logo-styles.css new file mode 100644 index 00000000..2ac57218 --- /dev/null +++ b/integration-tests/gradle/projects/it-basic/customResources/logo-styles.css @@ -0,0 +1,3 @@ +#logo { + background-image: url('https://upload.wikimedia.org/wikipedia/commons/9/9d/Ubuntu_logo.svg'); +} \ No newline at end of file diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicGradleIntegrationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicGradleIntegrationTest.kt index 46306078..9da67fc3 100644 --- a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicGradleIntegrationTest.kt +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/BasicGradleIntegrationTest.kt @@ -25,6 +25,8 @@ class BasicGradleIntegrationTest(override val versions: BuildVersions) : Abstrac .forEach { topLevelFile -> topLevelFile.copyTo(File(projectDir, topLevelFile.name)) } File(templateProjectDir, "src").copyRecursively(File(projectDir, "src")) + val customResourcesDir = File(templateProjectDir, "customResources") + if(customResourcesDir.exists() && customResourcesDir.isDirectory) customResourcesDir.copyRecursively(File(projectDir, "customResources")) } @Test @@ -116,6 +118,17 @@ class BasicGradleIntegrationTest(override val versions: BuildVersions) : Abstrac }, "Anchors should not have hashes inside" ) + + assertEquals( + """#logo{background-image:url('https://upload.wikimedia.org/wikipedia/commons/9/9d/Ubuntu_logo.svg');}""", + stylesDir.resolve("logo-styles.css").readText().replace("\\s".toRegex(), ""), + ) + assertTrue(stylesDir.resolve("custom-style-to-add.css").isFile) + assertEquals("""/* custom stylesheet */""", stylesDir.resolve("custom-style-to-add.css").readText()) + allHtmlFiles().forEach { file -> + if(file.name != "navigation.html") assertTrue("custom-style-to-add.css" in file.readText(), "custom styles not added to html file ${file.name}") + } + assertTrue(imagesDir.resolve("custom-resource.svg").isFile) } private fun File.assertJavadocOutputDir() { diff --git a/integration-tests/maven/projects/it-maven/customResources/custom-resource.svg b/integration-tests/maven/projects/it-maven/customResources/custom-resource.svg new file mode 100644 index 00000000..1865f739 --- /dev/null +++ b/integration-tests/maven/projects/it-maven/customResources/custom-resource.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/integration-tests/maven/projects/it-maven/customResources/custom-style-to-add.css b/integration-tests/maven/projects/it-maven/customResources/custom-style-to-add.css new file mode 100644 index 00000000..408c210e --- /dev/null +++ b/integration-tests/maven/projects/it-maven/customResources/custom-style-to-add.css @@ -0,0 +1 @@ +/* custom stylesheet */ \ No newline at end of file diff --git a/integration-tests/maven/projects/it-maven/customResources/logo-styles.css b/integration-tests/maven/projects/it-maven/customResources/logo-styles.css new file mode 100644 index 00000000..2ac57218 --- /dev/null +++ b/integration-tests/maven/projects/it-maven/customResources/logo-styles.css @@ -0,0 +1,3 @@ +#logo { + background-image: url('https://upload.wikimedia.org/wikipedia/commons/9/9d/Ubuntu_logo.svg'); +} \ No newline at end of file diff --git a/integration-tests/maven/projects/it-maven/pom.xml b/integration-tests/maven/projects/it-maven/pom.xml index 80620c82..8bd5d956 100644 --- a/integration-tests/maven/projects/it-maven/pom.xml +++ b/integration-tests/maven/projects/it-maven/pom.xml @@ -137,6 +137,17 @@ false + + + + ${project.basedir}/customResources/custom-resource.svg + + + ${project.basedir}/customResources/logo-styles.css + ${project.basedir}/customResources/custom-style-to-add.css + + + diff --git a/integration-tests/maven/src/integrationTest/kotlin/org/jetbrains/dokka/it/maven/MavenIntegrationTest.kt b/integration-tests/maven/src/integrationTest/kotlin/org/jetbrains/dokka/it/maven/MavenIntegrationTest.kt index 88fdc207..be70fdb4 100644 --- a/integration-tests/maven/src/integrationTest/kotlin/org/jetbrains/dokka/it/maven/MavenIntegrationTest.kt +++ b/integration-tests/maven/src/integrationTest/kotlin/org/jetbrains/dokka/it/maven/MavenIntegrationTest.kt @@ -24,6 +24,10 @@ class MavenIntegrationTest : AbstractIntegrationTest() { pomXml.apply { writeText(readText().replace("\$dokka_version", currentDokkaVersion)) } + val customResourcesDir = File(templateProjectDir, "customResources") + if(customResourcesDir.exists() && customResourcesDir.isDirectory) { + customResourcesDir.copyRecursively(File(projectDir, "customResources"), overwrite = true) + } } @Test @@ -54,6 +58,17 @@ class MavenIntegrationTest : AbstractIntegrationTest() { assertNoEmptyLinks(file) assertNoEmptySpans(file) } + + assertEquals( + """#logo{background-image:url('https://upload.wikimedia.org/wikipedia/commons/9/9d/Ubuntu_logo.svg');}""", + stylesDir.resolve("logo-styles.css").readText().replace("\\s".toRegex(), ""), + ) + assertTrue(stylesDir.resolve("custom-style-to-add.css").isFile) + projectDir.allHtmlFiles().forEach { file -> + if(file.name != "navigation.html") assertTrue("custom-style-to-add.css" in file.readText(), "custom styles not added to html file ${file.name}") + } + assertEquals("""/* custom stylesheet */""", stylesDir.resolve("custom-style-to-add.css").readText()) + assertTrue(imagesDir.resolve("custom-resource.svg").isFile) } @Test -- cgit