aboutsummaryrefslogtreecommitdiff
path: root/core/src/main
diff options
context:
space:
mode:
authorSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2017-05-02 15:08:52 +0300
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2017-05-02 16:51:03 +0300
commit54c3c87acfb31afc22afc5f20229384f755b677f (patch)
tree276b600a967ab9a2b710ae62e2acc1443d395c7d /core/src/main
parentacbe2f8c47a81c8e6046214f600ffdef24890fa6 (diff)
downloaddokka-54c3c87acfb31afc22afc5f20229384f755b677f.tar.gz
dokka-54c3c87acfb31afc22afc5f20229384f755b677f.tar.bz2
dokka-54c3c87acfb31afc22afc5f20229384f755b677f.zip
Refactoring internal communication for gradle
Diffstat (limited to 'core/src/main')
-rw-r--r--core/src/main/kotlin/DokkaBootstrapImpl.kt42
-rw-r--r--core/src/main/kotlin/Generation/DokkaGenerator.kt5
-rw-r--r--core/src/main/kotlin/Generation/configurationImpl.kt46
-rw-r--r--core/src/main/kotlin/Kotlin/DocumentationBuilder.kt3
-rw-r--r--core/src/main/kotlin/Model/SourceLinks.kt2
5 files changed, 59 insertions, 39 deletions
diff --git a/core/src/main/kotlin/DokkaBootstrapImpl.kt b/core/src/main/kotlin/DokkaBootstrapImpl.kt
index 8b10a5e8..fafa5daa 100644
--- a/core/src/main/kotlin/DokkaBootstrapImpl.kt
+++ b/core/src/main/kotlin/DokkaBootstrapImpl.kt
@@ -1,14 +1,8 @@
package org.jetbrains.dokka
-import java.io.File
+import ru.yole.jkid.deserialization.deserialize
import java.util.function.BiConsumer
-fun parseSourceLinkDefinition(srcLink: String): SourceLinkDefinition {
- val (path, urlAndLine) = srcLink.split('=')
- return SourceLinkDefinition(File(path).absolutePath,
- urlAndLine.substringBefore("#"),
- urlAndLine.substringAfter("#", "").let { if (it.isEmpty()) null else "#" + it })
-}
fun parsePerPackageOptions(arg: String): List<PackageOptions> {
if (arg.isBlank()) return emptyList()
@@ -25,14 +19,9 @@ fun parsePerPackageOptions(arg: String): List<PackageOptions> {
}
}
-fun parseSourceRoot(sourceRoot: String): SourceRoot {
- val components = sourceRoot.split("::", limit = 2)
- return SourceRoot(components.last(), if (components.size == 1) listOf() else components[0].split(','))
-}
-
class DokkaBootstrapImpl : DokkaBootstrap {
- class DokkaProxyLogger(val consumer: BiConsumer<String, String>) : DokkaLogger {
+ private class DokkaProxyLogger(val consumer: BiConsumer<String, String>) : DokkaLogger {
override fun info(message: String) {
consumer.accept("info", message)
}
@@ -48,26 +37,14 @@ class DokkaBootstrapImpl : DokkaBootstrap {
lateinit var generator: DokkaGenerator
- override fun configure(logger: BiConsumer<String, String>,
- moduleName: String,
- classpath: List<String>,
- sources: List<String>,
- samples: List<String>,
- includes: List<String>,
- outputDir: String,
- format: String,
- includeNonPublic: Boolean,
- includeRootPackage: Boolean,
- reportUndocumented: Boolean,
- skipEmptyPackages: Boolean,
- skipDeprecated: Boolean,
- jdkVersion: Int,
- generateIndexPages: Boolean,
- sourceLinks: List<String>) {
+ override fun configure(logger: BiConsumer<String, String>, serializedConfigurationJSON: String)
+ = configure(DokkaProxyLogger(logger), deserialize<DokkaConfigurationImpl>(serializedConfigurationJSON))
+
+ fun configure(logger: DokkaLogger, configuration: DokkaConfiguration) = with(configuration) {
generator = DokkaGenerator(
- DokkaProxyLogger(logger),
+ logger,
classpath,
- sources.map(::parseSourceRoot),
+ sourceRoots,
samples,
includes,
moduleName,
@@ -81,10 +58,9 @@ class DokkaBootstrapImpl : DokkaBootstrap {
skipDeprecated,
jdkVersion,
generateIndexPages,
- sourceLinks.map(::parseSourceLinkDefinition)
+ sourceLinks
)
)
-
}
override fun generate() = generator.generate()
diff --git a/core/src/main/kotlin/Generation/DokkaGenerator.kt b/core/src/main/kotlin/Generation/DokkaGenerator.kt
index 6b5df7c9..67c641a0 100644
--- a/core/src/main/kotlin/Generation/DokkaGenerator.kt
+++ b/core/src/main/kotlin/Generation/DokkaGenerator.kt
@@ -7,6 +7,7 @@ import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.psi.PsiFile
import com.intellij.psi.PsiJavaFile
import com.intellij.psi.PsiManager
+import org.jetbrains.dokka.DokkaConfiguration.SourceRoot
import org.jetbrains.dokka.Utilities.DokkaAnalysisModule
import org.jetbrains.dokka.Utilities.DokkaOutputModule
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation
@@ -23,10 +24,6 @@ import org.jetbrains.kotlin.utils.PathUtil
import java.io.File
import kotlin.system.measureTimeMillis
-class SourceRoot(path: String, val defaultPlatforms: List<String> = emptyList()) {
- val path: String = File(path).absolutePath
-}
-
class DokkaGenerator(val logger: DokkaLogger,
val classpath: List<String>,
val sources: List<SourceRoot>,
diff --git a/core/src/main/kotlin/Generation/configurationImpl.kt b/core/src/main/kotlin/Generation/configurationImpl.kt
new file mode 100644
index 00000000..6ed0d639
--- /dev/null
+++ b/core/src/main/kotlin/Generation/configurationImpl.kt
@@ -0,0 +1,46 @@
+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 defaultPlatforms: List<String> = emptyList()) : SourceRoot {
+ override val path: String = File(path).absolutePath
+
+ companion object {
+ fun parseSourceRoot(sourceRoot: String): SourceRoot {
+ val components = sourceRoot.split("::", limit = 2)
+ return SourceRootImpl(components.last(), if (components.size == 1) listOf() else components[0].split(','))
+ }
+ }
+}
+
+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>) : DokkaConfiguration \ No newline at end of file
diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
index 7c4e4531..aa4eed24 100644
--- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
+++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
@@ -3,6 +3,7 @@ package org.jetbrains.dokka
import com.google.inject.Inject
import com.intellij.openapi.util.text.StringUtil
import com.intellij.psi.PsiJavaFile
+import org.jetbrains.dokka.DokkaConfiguration.SourceLinkDefinition
import org.jetbrains.dokka.Kotlin.DescriptorDocumentationParser
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.*
@@ -873,7 +874,7 @@ fun CallableMemberDescriptor.getExtensionClassDescriptor(): ClassifierDescriptor
if (extensionReceiver != null) {
val type = extensionReceiver.type
val receiverClass = type.constructor.declarationDescriptor as? ClassDescriptor
- if ((receiverClass as? ClassDescriptor)?.isCompanionObject ?: false) {
+ if (receiverClass?.isCompanionObject ?: false) {
return receiverClass?.containingDeclaration as? ClassifierDescriptor
}
return receiverClass
diff --git a/core/src/main/kotlin/Model/SourceLinks.kt b/core/src/main/kotlin/Model/SourceLinks.kt
index 99bb8f60..2c75cfda 100644
--- a/core/src/main/kotlin/Model/SourceLinks.kt
+++ b/core/src/main/kotlin/Model/SourceLinks.kt
@@ -3,10 +3,10 @@ package org.jetbrains.dokka
import com.intellij.psi.PsiDocumentManager
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiNameIdentifierOwner
+import org.jetbrains.dokka.DokkaConfiguration.SourceLinkDefinition
import org.jetbrains.kotlin.psi.psiUtil.startOffset
import java.io.File
-class SourceLinkDefinition(val path: String, val url: String, val lineSuffix: String?)
fun DocumentationNode.appendSourceLink(psi: PsiElement?, sourceLinks: List<SourceLinkDefinition>) {
val path = psi?.containingFile?.virtualFile?.path ?: return