diff options
author | Kamil Doległo <kamilok1965@interia.pl> | 2020-01-31 00:37:29 +0100 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-01-31 15:27:26 +0100 |
commit | e99be615ce7c2c2b5c3ee5e3f8941c41c1e7a944 (patch) | |
tree | 7e3eb4f67d36d3b7b6db6aec08c58de2e1b678d3 /core/src/main | |
parent | 0073c4c547dafaae5d465d4c410a52fd7fdc818d (diff) | |
download | dokka-e99be615ce7c2c2b5c3ee5e3f8941c41c1e7a944.tar.gz dokka-e99be615ce7c2c2b5c3ee5e3f8941c41c1e7a944.tar.bz2 dokka-e99be615ce7c2c2b5c3ee5e3f8941c41c1e7a944.zip |
Bump Gradle version, migrate to Kotlin DSL, refactor publishing
Diffstat (limited to 'core/src/main')
-rw-r--r-- | core/src/main/kotlin/DokkaBootstrap.kt | 10 | ||||
-rw-r--r-- | core/src/main/kotlin/Java/JavadocParser.kt | 4 | ||||
-rw-r--r-- | core/src/main/kotlin/configuration.kt | 98 | ||||
-rw-r--r-- | core/src/main/kotlin/defaultConfiguration.kt | 74 |
4 files changed, 182 insertions, 4 deletions
diff --git a/core/src/main/kotlin/DokkaBootstrap.kt b/core/src/main/kotlin/DokkaBootstrap.kt new file mode 100644 index 00000000..b78eb9c6 --- /dev/null +++ b/core/src/main/kotlin/DokkaBootstrap.kt @@ -0,0 +1,10 @@ +package org.jetbrains.dokka + +import java.util.function.BiConsumer + +interface DokkaBootstrap { + + fun configure(logger: BiConsumer<String, String>, serializedConfigurationJSON: String) + + fun generate() +}
\ No newline at end of file diff --git a/core/src/main/kotlin/Java/JavadocParser.kt b/core/src/main/kotlin/Java/JavadocParser.kt index 5058634a..856cfa04 100644 --- a/core/src/main/kotlin/Java/JavadocParser.kt +++ b/core/src/main/kotlin/Java/JavadocParser.kt @@ -4,16 +4,12 @@ import com.intellij.psi.* import com.intellij.psi.impl.source.tree.JavaDocElementType import com.intellij.psi.javadoc.* import com.intellij.psi.util.PsiTreeUtil -import com.intellij.util.containers.isNullOrEmpty -import kotlinx.html.P import org.jetbrains.dokka.model.doc.* import org.jetbrains.dokka.utilities.DokkaLogger -import org.jetbrains.kotlin.utils.keysToMap import org.jsoup.Jsoup import org.jsoup.nodes.Element import org.jsoup.nodes.Node import org.jsoup.nodes.TextNode -import java.net.URI interface JavaDocumentationParser { fun parseDocumentation(element: PsiNamedElement): DocumentationNode diff --git a/core/src/main/kotlin/configuration.kt b/core/src/main/kotlin/configuration.kt new file mode 100644 index 00000000..8c6d35e8 --- /dev/null +++ b/core/src/main/kotlin/configuration.kt @@ -0,0 +1,98 @@ +package org.jetbrains.dokka + +import java.io.File +import java.net.URL + +enum class Platform(val key: String) { + jvm("jvm"), + js("js"), + native("native"), + common("common"); + + companion object { + val DEFAULT = jvm + + fun fromString(key: String): Platform { + return when (key.toLowerCase()) { + jvm.key -> jvm + js.key -> js + native.key -> native + common.key -> common + else -> throw IllegalArgumentException("Unrecognized platform: $key") + } + } + } +} + +interface DokkaConfiguration { + val outputDir: String + val format: String + val generateIndexPages: Boolean + val cacheRoot: String? + val passesConfigurations: List<PassConfiguration> + val impliedPlatforms: List<String> + var pluginsClasspath: List<File> + + interface PassConfiguration { + val moduleName: String + val classpath: List<String> + val sourceRoots: List<SourceRoot> + val samples: List<String> + val includes: List<String> + val includeNonPublic: Boolean + val includeRootPackage: Boolean + val reportUndocumented: Boolean + val skipEmptyPackages: Boolean + val skipDeprecated: Boolean + val jdkVersion: Int + val sourceLinks: List<SourceLinkDefinition> + val perPackageOptions: List<PackageOptions> + val externalDocumentationLinks: List<ExternalDocumentationLink> + val languageVersion: String? + val apiVersion: String? + val noStdlibLink: Boolean + val noJdkLink: Boolean + val suppressedFiles: List<String> + val collectInheritedExtensionsFromLibraries: Boolean + val analysisPlatform: Platform + val targets: List<String> + val sinceKotlin: String? + } + + interface SourceRoot { + val path: String + } + + interface SourceLinkDefinition { + val path: String + val url: String + val lineSuffix: String? + } + + interface PackageOptions { + val prefix: String + val includeNonPublic: Boolean + val reportUndocumented: Boolean + val skipDeprecated: Boolean + val suppress: Boolean + } + + interface ExternalDocumentationLink { + val url: URL + val packageListUrl: URL + + open class Builder(open var url: URL? = null, + open var packageListUrl: URL? = null) { + + constructor(root: String, packageList: String? = null) : this(URL(root), packageList?.let { URL(it) }) + + fun build(): ExternalDocumentationLink = + if (packageListUrl != null && url != null) + ExternalDocumentationLinkImpl(url!!, packageListUrl!!) + else if (url != null) + ExternalDocumentationLinkImpl(url!!, URL(url!!, "package-list")) + else + throw IllegalArgumentException("url or url && packageListUrl must not be null for external documentation link") + } + } +} diff --git a/core/src/main/kotlin/defaultConfiguration.kt b/core/src/main/kotlin/defaultConfiguration.kt new file mode 100644 index 00000000..6c797fcd --- /dev/null +++ b/core/src/main/kotlin/defaultConfiguration.kt @@ -0,0 +1,74 @@ +package org.jetbrains.dokka + +import java.io.File +import java.net.URL + +data class DokkaConfigurationImpl( + override val outputDir: String, + override val format: String, + override val generateIndexPages: Boolean, + override val cacheRoot: String?, + override val impliedPlatforms: List<String>, + override val passesConfigurations: List<PassConfigurationImpl>, + override var pluginsClasspath: List<File> +) : DokkaConfiguration + +data class PassConfigurationImpl ( + 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 includeNonPublic: Boolean, + override val includeRootPackage: Boolean, + override val reportUndocumented: Boolean, + override val skipEmptyPackages: Boolean, + override val skipDeprecated: Boolean, + override val jdkVersion: Int, + override val sourceLinks: List<SourceLinkDefinitionImpl>, + override val perPackageOptions: List<PackageOptionsImpl>, + override var externalDocumentationLinks: List<ExternalDocumentationLinkImpl>, + override val languageVersion: String?, + override val apiVersion: String?, + override val noStdlibLink: Boolean, + override val noJdkLink: Boolean, + override val suppressedFiles: List<String>, + override val collectInheritedExtensionsFromLibraries: Boolean, + override val analysisPlatform: Platform, + override val targets: List<String>, + override val sinceKotlin: String? +) : DokkaConfiguration.PassConfiguration + + +data class SourceRootImpl( + override val path: String +): DokkaConfiguration.SourceRoot + +data class SourceLinkDefinitionImpl( + override val path: String, + override val url: String, + override val lineSuffix: String? +): DokkaConfiguration.SourceLinkDefinition { + companion object { + fun parseSourceLinkDefinition(srcLink: String): SourceLinkDefinitionImpl { + val (path, urlAndLine) = srcLink.split('=') + return SourceLinkDefinitionImpl( + File(path).canonicalPath, + urlAndLine.substringBefore("#"), + urlAndLine.substringAfter("#", "").let { if (it.isEmpty()) null else "#$it" }) + } + } +} + +data class PackageOptionsImpl( + override val prefix: String, + override val includeNonPublic: Boolean, + override val reportUndocumented: Boolean, + override val skipDeprecated: Boolean, + override val suppress: Boolean +): DokkaConfiguration.PackageOptions + + +data class ExternalDocumentationLinkImpl(override val url: URL, + override val packageListUrl: URL +) : DokkaConfiguration.ExternalDocumentationLink
\ No newline at end of file |