|
| 1 | +/* |
| 2 | + * Copyright 2022, TeamDev. All rights reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Redistribution and use in source and/or binary forms, with or without |
| 11 | + * modification, must retain the above copyright notice and the following |
| 12 | + * disclaimer. |
| 13 | + * |
| 14 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 15 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 16 | + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 17 | + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 18 | + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 19 | + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 20 | + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 21 | + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 22 | + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 | + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 | + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 | + */ |
| 26 | + |
| 27 | +import io.spine.internal.dependency.Dokka |
| 28 | +import io.spine.internal.gradle.dokka.onlyJavaSources |
| 29 | +import io.spine.internal.gradle.dokka.onlyNonGeneratedSources |
| 30 | + |
| 31 | +import java.time.LocalDate |
| 32 | +import org.jetbrains.dokka.base.DokkaBase |
| 33 | +import org.jetbrains.dokka.base.DokkaBaseConfiguration |
| 34 | +import org.jetbrains.dokka.gradle.DokkaTask |
| 35 | + |
| 36 | +plugins { |
| 37 | + id("org.jetbrains.dokka") |
| 38 | +} |
| 39 | + |
| 40 | +dependencies { |
| 41 | + /** |
| 42 | + * To generate the documentation as seen from Java perspective, the kotlin-as-java plugin was |
| 43 | + * added to the Dokka's classpath. |
| 44 | + * |
| 45 | + * @see <a href="https://github.com/Kotlin/dokka#output-formats"> |
| 46 | + * Dokka output formats</a> |
| 47 | + */ |
| 48 | + dokkaPlugin(Dokka.KotlinAsJavaPlugin.lib) |
| 49 | + |
| 50 | + /** |
| 51 | + * To exclude pieces of code annotated with `@Internal` from the documentation a custom plugin |
| 52 | + * is added to the Dokka's classpath. |
| 53 | + * |
| 54 | + * @see <a href="https://github.com/SpineEventEngine/dokka-tools/tree/master/dokka-extensions"> |
| 55 | + * Custom Dokka Plugins</a> |
| 56 | + */ |
| 57 | + dokkaPlugin(Dokka.SpineExtensions.lib) |
| 58 | +} |
| 59 | + |
| 60 | +tasks.withType<DokkaTask>().configureEach { |
| 61 | + dokkaSourceSets.configureEach { |
| 62 | + sourceRoots.setFrom( |
| 63 | + onlyJavaSources() |
| 64 | + ) |
| 65 | + |
| 66 | + sourceRoots.setFrom( |
| 67 | + onlyNonGeneratedSources() |
| 68 | + ) |
| 69 | + |
| 70 | + skipEmptyPackages.set(true) |
| 71 | + } |
| 72 | + |
| 73 | + outputDirectory.set(buildDir.resolve("docs/dokka")) |
| 74 | + |
| 75 | + val dokkaConfDir = rootDir.resolve("buildSrc/src/main/resources/dokka") |
| 76 | + |
| 77 | + /** |
| 78 | + * Dokka Base plugin allows to set a few properties to customize the output: |
| 79 | + * |
| 80 | + * - `customStyleSheets` property to which we can pass our css files overriding styles generated |
| 81 | + * by Dokka; |
| 82 | + * - `customAssets` property to provide resources. We need to provide an image with the name |
| 83 | + * "logo-icon.svg" to overwrite the default one used by Dokka; |
| 84 | + * - `separateInheritedMembers` when set to `true`, creates a separate tab in type-documentation |
| 85 | + * for inherited members. |
| 86 | + * |
| 87 | + * @see <a href="https://kotlin.github.io/dokka/1.6.10/user_guide/base-specific/frontend/#prerequisites"> |
| 88 | + * Dokka modifying frontend assets</a> |
| 89 | + */ |
| 90 | + pluginConfiguration<DokkaBase, DokkaBaseConfiguration> { |
| 91 | + customStyleSheets = listOf(file("${dokkaConfDir.resolve("styles/custom-styles.css")}")) |
| 92 | + customAssets = listOf(file("${dokkaConfDir.resolve("assets/logo-icon.svg")}")) |
| 93 | + separateInheritedMembers = true |
| 94 | + footerMessage = "Copyright ${LocalDate.now().year}, TeamDev" |
| 95 | + } |
| 96 | +} |
0 commit comments