aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/Generation/configurationImpl.kt
blob: 0d916345db504598bf807eb5424e59f103b578e2 (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
package org.jetbrains.dokka

import org.jetbrains.dokka.DokkaConfiguration.SourceLinkDefinition
import org.jetbrains.dokka.DokkaConfiguration.SourceRoot
import java.io.File


data class SourceLinkDefinitionImpl(override val path: String,
                                    override val url: String,
                                    override val lineSuffix: String?) : SourceLinkDefinition {
    companion object {
        fun parseSourceLinkDefinition(srcLink: String): SourceLinkDefinition {
            val (path, urlAndLine) = srcLink.split('=')
            return SourceLinkDefinitionImpl(File(path).absolutePath,
                    urlAndLine.substringBefore("#"),
                    urlAndLine.substringAfter("#", "").let { if (it.isEmpty()) null else "#" + it })
        }
    }
}

class SourceRootImpl(path: String, override val platforms: List<String> = emptyList(),
                     override val analysisPlatform: Platform = Platform.DEFAULT) : SourceRoot {
    override val path: String = File(path).absolutePath

    companion object {
        fun parseSourceRoot(sourceRoot: String): SourceRoot {
            val components = sourceRoot.split("::", limit = 2)

            // TODO: create syntax for cli
            val platform = if (components.size == 1) {
                Platform.DEFAULT
            } else {
                Platform.fromString(components[0])
            }

            return SourceRootImpl(components.last(), emptyList(), platform)
        }
    }
}

data class PackageOptionsImpl(override val prefix: String,
                              override val includeNonPublic: Boolean = false,
                              override val reportUndocumented: Boolean = true,
                              override val skipDeprecated: Boolean = false,
                              override val suppress: Boolean = false) : DokkaConfiguration.PackageOptions

data class DokkaConfigurationImpl(
        override val moduleName: String,
        override val classpath: List<String>,
        override val sourceRoots: List<SourceRootImpl>,
        override val samples: List<String>,
        override val includes: List<String>,
        override val outputDir: String,
        override val format: String,
        override val includeNonPublic: Boolean,
        override val includeRootPackage: Boolean,
        override val reportUndocumented: Boolean,
        override val skipEmptyPackages: Boolean,
        override val skipDeprecated: Boolean,
        override val jdkVersion: Int,
        override val generateIndexPages: Boolean,
        override val sourceLinks: List<SourceLinkDefinitionImpl>,
        override val impliedPlatforms: List<String>,
        override val perPackageOptions: List<PackageOptionsImpl>,
        override val externalDocumentationLinks: List<ExternalDocumentationLinkImpl>,
        override val noStdlibLink: Boolean,
        override val cacheRoot: String?,
        override val suppressedFiles: List<String>,
        override val languageVersion: String?,
        override val apiVersion: String?
) : DokkaConfiguration