aboutsummaryrefslogtreecommitdiff
path: root/core/src/main
diff options
context:
space:
mode:
authorKamil Doległo <kamilok1965@interia.pl>2019-03-22 11:58:29 +0100
committerKamil Doległo <kamilok1965@interia.pl>2019-03-27 15:18:59 +0100
commit93bef428ae2e1f4952a22adfd4a2aa679ddd7605 (patch)
tree0460ebc4f59e943ce426a459f87fbfbcde76e53a /core/src/main
parent23219d692d809da29151add0d112c7983f214577 (diff)
downloaddokka-93bef428ae2e1f4952a22adfd4a2aa679ddd7605.tar.gz
dokka-93bef428ae2e1f4952a22adfd4a2aa679ddd7605.tar.bz2
dokka-93bef428ae2e1f4952a22adfd4a2aa679ddd7605.zip
Rework configuration, fix Gradle plugin
Diffstat (limited to 'core/src/main')
-rw-r--r--core/src/main/kotlin/DokkaBootstrapImpl.kt37
-rw-r--r--core/src/main/kotlin/Generation/configurationImpl.kt80
-rw-r--r--core/src/main/kotlin/Java/JavadocParser.kt5
-rw-r--r--core/src/main/kotlin/Kotlin/DocumentationBuilder.kt2
-rw-r--r--core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt2
-rw-r--r--core/src/main/kotlin/Utilities/ServiceLocator.kt2
6 files changed, 37 insertions, 91 deletions
diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt
index ccafcd12..2077458a 100644
--- a/core/src/main/kotlin/DokkaBootstrapImpl.kt
+++ b/core/src/main/kotlin/DokkaBootstrapImpl.kt
@@ -1,7 +1,10 @@
package org.jetbrains.dokka
+import com.intellij.openapi.util.Pass
+import kotlinx.serialization.*
+import kotlinx.serialization.json.Json
import org.jetbrains.dokka.DokkaConfiguration.PackageOptions
-import ru.yole.jkid.deserialization.deserialize
+
import java.util.function.BiConsumer
@@ -40,11 +43,35 @@ class DokkaBootstrapImpl : DokkaBootstrap {
lateinit var generator: DokkaGenerator
override fun configure(logger: BiConsumer<String, String>, serializedConfigurationJSON: String)
- = configure(DokkaProxyLogger(logger), deserialize<DokkaConfigurationImpl>(serializedConfigurationJSON))
+ = configure(DokkaProxyLogger(logger), Json.parse(DokkaConfigurationImpl.serializer(), serializedConfigurationJSON))
+
+ fun configure(logger: DokkaLogger, configuration: DokkaConfigurationImpl) = with(configuration) {
- fun configure(logger: DokkaLogger, configuration: DokkaConfiguration) = with(configuration) {
- generator = DokkaGenerator(configuration, logger)
+ fun defaultLinks(config: PassConfigurationImpl): List<ExternalDocumentationLinkImpl> {
+ val links = mutableListOf<ExternalDocumentationLinkImpl>()
+ if (!config.noJdkLink)
+ links += DokkaConfiguration.ExternalDocumentationLink
+ .Builder("https://docs.oracle.com/javase/${config.jdkVersion}/docs/api/")
+ .build() as ExternalDocumentationLinkImpl
+
+ if (!config.noStdlibLink)
+ links += DokkaConfiguration.ExternalDocumentationLink
+ .Builder("https://kotlinlang.org/api/latest/jvm/stdlib/")
+ .build() as ExternalDocumentationLinkImpl
+ return links
+ }
+
+ val configurationWithLinks =
+ configuration.copy(passesConfigurations =
+ passesConfigurations
+ .map {
+ val links: List<ExternalDocumentationLinkImpl> = it.externalDocumentationLinks + defaultLinks(it)
+ it.copy(externalDocumentationLinks = links)
+ }
+ )
+
+ generator = DokkaGenerator(configurationWithLinks, logger)
}
override fun generate() = generator.generate()
-} \ No newline at end of file
+}
diff --git a/core/src/main/kotlin/Generation/configurationImpl.kt b/core/src/main/kotlin/Generation/configurationImpl.kt
deleted file mode 100644
index 46174198..00000000
--- a/core/src/main/kotlin/Generation/configurationImpl.kt
+++ /dev/null
@@ -1,80 +0,0 @@
-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).canonicalPath,
- urlAndLine.substringBefore("#"),
- urlAndLine.substringAfter("#", "").let { if (it.isEmpty()) null else "#$it" })
- }
- }
-}
-
-class SourceRootImpl(path: String) : SourceRoot {
- override val path: String = File(path).absolutePath
-
- companion object {
- fun parseSourceRoot(sourceRoot: String): SourceRoot = SourceRootImpl(sourceRoot)
- }
-}
-
-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 outputDir: String = "",
- override val format: String = "html",
- override val generateIndexPages: Boolean = false,
- override val cacheRoot: String? = null,
- override val impliedPlatforms: List<String> = listOf(),
- override val passesConfigurations: List<DokkaConfiguration.PassConfiguration> = listOf()
-) : DokkaConfiguration
-
-class PassConfigurationImpl (
- override val classpath: List<String> = listOf(),
- override val moduleName: String = "",
- override val sourceRoots: List<SourceRoot> = listOf(),
- override val samples: List<String> = listOf(),
- override val includes: List<String> = listOf(),
- override val includeNonPublic: Boolean = false,
- override val includeRootPackage: Boolean = false,
- override val reportUndocumented: Boolean = false,
- override val skipEmptyPackages: Boolean = false,
- override val skipDeprecated: Boolean = false,
- override val jdkVersion: Int = 6,
- override val sourceLinks: List<SourceLinkDefinition> = listOf(),
- override val perPackageOptions: List<DokkaConfiguration.PackageOptions> = listOf(),
- externalDocumentationLinks: List<DokkaConfiguration.ExternalDocumentationLink> = listOf(),
- override val languageVersion: String? = null,
- override val apiVersion: String? = null,
- override val noStdlibLink: Boolean = false,
- override val noJdkLink: Boolean = false,
- override val suppressedFiles: List<String> = listOf(),
- override val collectInheritedExtensionsFromLibraries: Boolean = false,
- override val analysisPlatform: Platform = Platform.DEFAULT,
- override val targets: List<String> = listOf(),
- override val sinceKotlin: String = "1.0"
-): DokkaConfiguration.PassConfiguration {
- private val defaultLinks = run {
- val links = mutableListOf<DokkaConfiguration.ExternalDocumentationLink>()
- if (!noJdkLink)
- links += DokkaConfiguration.ExternalDocumentationLink.Builder("https://docs.oracle.com/javase/$jdkVersion/docs/api/").build()
-
- if (!noStdlibLink)
- links += DokkaConfiguration.ExternalDocumentationLink.Builder("https://kotlinlang.org/api/latest/jvm/stdlib/").build()
- links
- }
- override val externalDocumentationLinks = defaultLinks + externalDocumentationLinks
-}
-
diff --git a/core/src/main/kotlin/Java/JavadocParser.kt b/core/src/main/kotlin/Java/JavadocParser.kt
index 70af73f9..66db46d7 100644
--- a/core/src/main/kotlin/Java/JavadocParser.kt
+++ b/core/src/main/kotlin/Java/JavadocParser.kt
@@ -234,9 +234,8 @@ class JavadocParser(
linkSignature != null -> {
val linkNode =
ContentNodeLazyLink(
- (tag.valueElement ?: linkElement).text,
- { -> refGraph.lookupOrWarn(linkSignature, logger) }
- )
+ (tag.valueElement ?: linkElement).text
+ ) { -> refGraph.lookupOrWarn(linkSignature!!, logger) }
linkNode.append(text)
linkNode
}
diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
index e3f7c35b..d6413b64 100644
--- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
+++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
@@ -1156,7 +1156,7 @@ fun ClassDescriptor.supertypesWithAnyPrecise(): Collection<KotlinType> {
}
fun PassConfiguration.effectivePackageOptions(pack: String): DokkaConfiguration.PackageOptions {
- val rootPackageOptions = PackageOptionsImpl("", includeNonPublic, reportUndocumented, skipDeprecated)
+ val rootPackageOptions = PackageOptionsImpl("", includeNonPublic, reportUndocumented, skipDeprecated, false)
return perPackageOptions.firstOrNull { pack == it.prefix || pack.startsWith(it.prefix + ".") } ?: rootPackageOptions
}
diff --git a/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt b/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt
index 9d986aee..793f9589 100644
--- a/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt
+++ b/core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt
@@ -154,7 +154,7 @@ class PackageListProvider @Inject constructor(
.toMap()
- val defaultResolverDesc = ExternalDocumentationLinkResolver.services["dokka-default"]!!
+ val defaultResolverDesc = ExternalDocumentationLinkResolver.services.getValue("dokka-default")
val resolverDesc = ExternalDocumentationLinkResolver.services[format]
?: defaultResolverDesc.takeIf { format in formatsWithDefaultResolver }
?: defaultResolverDesc.also {
diff --git a/core/src/main/kotlin/Utilities/ServiceLocator.kt b/core/src/main/kotlin/Utilities/ServiceLocator.kt
index fca08f38..b2743c53 100644
--- a/core/src/main/kotlin/Utilities/ServiceLocator.kt
+++ b/core/src/main/kotlin/Utilities/ServiceLocator.kt
@@ -70,7 +70,7 @@ object ServiceLocator {
"jar" -> {
val file = JarFile(URL(it.file.substringBefore("!")).toFile())
try {
- val jarPath = it.file.substringAfterLast("!").removeSurrounding("/")
+ val jarPath = it.file.substringAfterLast("!").removePrefix("/") // TODO: revision b265a9ffacb8f8e8e6226a9458a92697b02355a8 - removeSurrounding for Ant breaks Gradle
file.entries()
.asSequence()
.filter { entry -> !entry.isDirectory && entry.path == jarPath && entry.extension == "properties" }