summaryrefslogtreecommitdiff
path: root/gradle/dokka.gradle
blob: 5a208f2b17f7ab06718424356f4cf91903d6daae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
 * Copyright 2017-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
 */

apply plugin: 'kotlin'
apply plugin: 'org.jetbrains.dokka'

def documentedSubprojects = ["kotlinx-serialization-core",
                             "kotlinx-serialization-json",
                             "kotlinx-serialization-json-okio",
                             "kotlinx-serialization-cbor",
                             "kotlinx-serialization-properties",
                             "kotlinx-serialization-hocon",
                             "kotlinx-serialization-protobuf"]

subprojects {
    if (!(name in documentedSubprojects)) return
    apply plugin: 'org.jetbrains.dokka'
    dependencies {
        dokkaPlugin("org.jetbrains.kotlinx:dokka-pathsaver-plugin:$knit_version")
    }

    tasks.named('dokkaHtmlPartial') {
        outputDirectory = file("build/dokka")
        pluginsMapConfiguration.set(["org.jetbrains.dokka.base.DokkaBase": """{ "templatesDir": "${rootProject.projectDir.toString().replace('\\', '/')}/dokka-templates" }"""])

        dokkaSourceSets {
            configureEach {
                includes.from(rootProject.file('dokka/moduledoc.md').path)

                perPackageOption {
                    matchingRegex.set("kotlinx\\.serialization(\$|\\.).*")
                    reportUndocumented.set(true)
                    skipDeprecated.set(true)
                }

                // Internal API
                perPackageOption {
                    matchingRegex.set("kotlinx\\.serialization.internal(\$|\\.).*")
                    suppress.set(true)
                }

                // Internal JSON API
                perPackageOption {
                    matchingRegex.set("kotlinx\\.serialization.json.internal(\$|\\.).*")
                    suppress.set(true)
                    reportUndocumented.set(false)
                }

                // Workaround for typealias
                perPackageOption {
                    matchingRegex.set("kotlinx\\.serialization.protobuf.internal(\$|\\.).*")
                    suppress.set(true)
                    reportUndocumented.set(false)
                }

                // Deprecated migrations
                perPackageOption {
                    matchingRegex.set("kotlinx\\.protobuf(\$|\\.).*")
                    reportUndocumented.set(true)
                    skipDeprecated.set(true)
                }

                // Deprecated migrations
                perPackageOption {
                    matchingRegex.set("org\\.jetbrains\\.kotlinx\\.serialization\\.config(\$|\\.).*")
                    reportUndocumented.set(false)
                    skipDeprecated.set(true)
                }

                // JS/Native implementation of JVM-only `org.intellij.lang.annotations.Language` class to add syntax support by IDE.
                perPackageOption {
                    matchingRegex.set("org\\.intellij\\.lang\\.annotations(\$|\\.).*")
                    suppress.set(true)
                }

                sourceLink {
                    localDirectory.set(rootDir)
                    remoteUrl.set(new URL("https://github.com/Kotlin/kotlinx.serialization/tree/master"))
                    remoteLineSuffix.set("#L")
                }
            }
        }
    }
}

// Knit relies on Dokka task and it's pretty convenient
task dokka(dependsOn: dokkaHtmlMultiModule) {}