diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/build.gradle | 4 | ||||
-rw-r--r-- | core/src/main/kotlin/DokkaBootstrapImpl.kt | 37 | ||||
-rw-r--r-- | core/src/main/kotlin/Java/JavadocParser.kt | 5 | ||||
-rw-r--r-- | core/src/main/kotlin/Kotlin/DocumentationBuilder.kt | 2 | ||||
-rw-r--r-- | core/src/main/kotlin/Kotlin/ExternalDocumentationLinkResolver.kt | 2 | ||||
-rw-r--r-- | core/src/main/kotlin/Utilities/ServiceLocator.kt | 2 | ||||
-rw-r--r-- | core/src/test/kotlin/DokkaConfigurationTestImplementations.kt (renamed from core/src/main/kotlin/Generation/configurationImpl.kt) | 41 |
7 files changed, 60 insertions, 33 deletions
diff --git a/core/build.gradle b/core/build.gradle index c90a7789..0008bfd7 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -12,8 +12,8 @@ sourceCompatibility = 1.8 tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { kotlinOptions { - languageVersion = "1.2" - apiVersion = languageVersion + languageVersion = language_version + apiVersion = language_version jvmTarget = "1.8" } } 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/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" } diff --git a/core/src/main/kotlin/Generation/configurationImpl.kt b/core/src/test/kotlin/DokkaConfigurationTestImplementations.kt index 46174198..19ec1e64 100644 --- a/core/src/main/kotlin/Generation/configurationImpl.kt +++ b/core/src/test/kotlin/DokkaConfigurationTestImplementations.kt @@ -1,28 +1,29 @@ -package org.jetbrains.dokka +package org.jetbrains.dokka.tests -import org.jetbrains.dokka.DokkaConfiguration.SourceLinkDefinition -import org.jetbrains.dokka.DokkaConfiguration.SourceRoot +import org.jetbrains.dokka.DokkaConfiguration +import org.jetbrains.dokka.Platform import java.io.File data class SourceLinkDefinitionImpl(override val path: String, override val url: String, - override val lineSuffix: String?) : SourceLinkDefinition { + override val lineSuffix: String?) : DokkaConfiguration.SourceLinkDefinition { companion object { - fun parseSourceLinkDefinition(srcLink: String): SourceLinkDefinition { + fun parseSourceLinkDefinition(srcLink: String): DokkaConfiguration.SourceLinkDefinition { val (path, urlAndLine) = srcLink.split('=') - return SourceLinkDefinitionImpl(File(path).canonicalPath, + return SourceLinkDefinitionImpl( + File(path).canonicalPath, urlAndLine.substringBefore("#"), urlAndLine.substringAfter("#", "").let { if (it.isEmpty()) null else "#$it" }) } } } -class SourceRootImpl(path: String) : SourceRoot { +class SourceRootImpl(path: String) : DokkaConfiguration.SourceRoot { override val path: String = File(path).absolutePath companion object { - fun parseSourceRoot(sourceRoot: String): SourceRoot = SourceRootImpl(sourceRoot) + fun parseSourceRoot(sourceRoot: String): DokkaConfiguration.SourceRoot = SourceRootImpl(sourceRoot) } } @@ -32,38 +33,38 @@ data class PackageOptionsImpl(override val prefix: String, override val skipDeprecated: Boolean = false, override val suppress: Boolean = false) : DokkaConfiguration.PackageOptions -data class DokkaConfigurationImpl( + 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() + override val impliedPlatforms: List<String> = emptyList(), + override val passesConfigurations: List<DokkaConfiguration.PassConfiguration> = emptyList() ) : DokkaConfiguration class PassConfigurationImpl ( - override val classpath: List<String> = listOf(), + override val classpath: List<String> = emptyList(), override val moduleName: String = "", - override val sourceRoots: List<SourceRoot> = listOf(), - override val samples: List<String> = listOf(), - override val includes: List<String> = listOf(), + override val sourceRoots: List<DokkaConfiguration.SourceRoot> = emptyList(), + override val samples: List<String> = emptyList(), + override val includes: List<String> = emptyList(), 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 sourceLinks: List<DokkaConfiguration.SourceLinkDefinition> = emptyList(), + override val perPackageOptions: List<DokkaConfiguration.PackageOptions> = emptyList(), + externalDocumentationLinks: List<DokkaConfiguration.ExternalDocumentationLink> = emptyList(), 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 suppressedFiles: List<String> = emptyList(), override val collectInheritedExtensionsFromLibraries: Boolean = false, override val analysisPlatform: Platform = Platform.DEFAULT, - override val targets: List<String> = listOf(), + override val targets: List<String> = emptyList(), override val sinceKotlin: String = "1.0" ): DokkaConfiguration.PassConfiguration { private val defaultLinks = run { |