aboutsummaryrefslogtreecommitdiff
path: root/core/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main')
-rw-r--r--core/src/main/kotlin/DokkaGenerator.kt36
-rw-r--r--core/src/main/kotlin/configuration.kt6
-rw-r--r--core/src/main/kotlin/defaultConfiguration.kt2
-rw-r--r--core/src/main/kotlin/model/Documentable.kt168
-rw-r--r--core/src/main/kotlin/model/SourceSetData.kt23
-rw-r--r--core/src/main/kotlin/model/aditionalExtras.kt4
-rw-r--r--core/src/main/kotlin/model/documentableUtils.kt15
-rw-r--r--core/src/main/kotlin/pages/ContentNodes.kt29
-rw-r--r--core/src/main/kotlin/pages/PageNodes.kt5
-rw-r--r--core/src/main/kotlin/plugability/DokkaContext.kt14
-rw-r--r--core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt2
-rw-r--r--core/src/main/kotlin/transformers/sources/SourceToDocumentableTranslator.kt4
12 files changed, 156 insertions, 152 deletions
diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt
index 053b4cb6..6e62c033 100644
--- a/core/src/main/kotlin/DokkaGenerator.kt
+++ b/core/src/main/kotlin/DokkaGenerator.kt
@@ -1,23 +1,20 @@
package org.jetbrains.dokka
-import com.intellij.openapi.vfs.VirtualFileManager
-import com.intellij.psi.PsiJavaFile
-import com.intellij.psi.PsiManager
import org.jetbrains.dokka.analysis.AnalysisEnvironment
import org.jetbrains.dokka.analysis.DokkaResolutionFacade
import org.jetbrains.dokka.model.DModule
-import org.jetbrains.dokka.pages.PlatformData
+import org.jetbrains.dokka.model.SourceSetCache
+import org.jetbrains.dokka.model.SourceSetData
+import org.jetbrains.dokka.model.sourceSet
import org.jetbrains.dokka.pages.RootPageNode
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.plugability.DokkaPlugin
import org.jetbrains.dokka.utilities.DokkaLogger
-import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
-import org.jetbrains.kotlin.cli.jvm.config.JavaSourceRoot
import org.jetbrains.kotlin.utils.PathUtil
import java.io.File
@@ -31,13 +28,14 @@ class DokkaGenerator(
) {
fun generate() = timed {
report("Setting up analysis environments")
- val platforms: Map<PlatformData, EnvironmentAndFacade> = setUpAnalysis(configuration)
+ val sourceSetsCache = SourceSetCache()
+ val sourceSets: Map<SourceSetData, EnvironmentAndFacade> = setUpAnalysis(configuration, sourceSetsCache)
report("Initializing plugins")
- val context = initializePlugins(configuration, logger, platforms)
+ val context = initializePlugins(configuration, logger, sourceSets, sourceSetsCache)
report("Creating documentation models")
- val modulesFromPlatforms = createDocumentationModels(platforms, context)
+ val modulesFromPlatforms = createDocumentationModels(sourceSets, context)
report("Transforming documentation model before merging")
val transformedDocumentationBeforeMerge = transformDocumentationModelBeforeMerge(modulesFromPlatforms, context)
@@ -62,27 +60,31 @@ class DokkaGenerator(
logger.report()
}.dump("\n\n === TIME MEASUREMENT ===\n")
- fun setUpAnalysis(configuration: DokkaConfiguration): Map<PlatformData, EnvironmentAndFacade> =
+ fun setUpAnalysis(
+ configuration: DokkaConfiguration,
+ sourceSetsCache: SourceSetCache
+ ): Map<SourceSetData, EnvironmentAndFacade> =
configuration.passesConfigurations.map {
- it.platformData to createEnvironmentAndFacade(it)
+ sourceSetsCache.getSourceSet(it) to createEnvironmentAndFacade(it)
}.toMap()
fun initializePlugins(
configuration: DokkaConfiguration,
logger: DokkaLogger,
- platforms: Map<PlatformData, EnvironmentAndFacade>,
+ sourceSets: Map<SourceSetData, EnvironmentAndFacade>,
+ sourceSetsCache: SourceSetCache,
pluginOverrides: List<DokkaPlugin> = emptyList()
- ) = DokkaContext.create(configuration, logger, platforms, pluginOverrides)
+ ) = DokkaContext.create(configuration, logger, sourceSets, sourceSetsCache, pluginOverrides)
fun createDocumentationModels(
- platforms: Map<PlatformData, EnvironmentAndFacade>,
+ platforms: Map<SourceSetData, EnvironmentAndFacade>,
context: DokkaContext
) = platforms.flatMap { (pdata, _) -> translateSources(pdata, context) }
fun transformDocumentationModelBeforeMerge(
modulesFromPlatforms: List<DModule>,
context: DokkaContext
- ) = context[CoreExtensions.preMergeDocumentableTransformer].fold(modulesFromPlatforms) { acc, t -> t(acc, context) }
+ ) = context[CoreExtensions.preMergeDocumentableTransformer].fold(modulesFromPlatforms) { acc, t -> t(acc) }
fun mergeDocumentationModels(
modulesFromPlatforms: List<DModule>,
@@ -119,7 +121,7 @@ class DokkaGenerator(
}
pass.classpath.forEach { addClasspath(File(it)) }
- addSources(pass.sourceRoots.map { it.path })
+ addSources((pass.sourceRoots + pass.dependentSourceRoots).map { it.path })
loadLanguageVersionSettings(pass.languageVersion, pass.apiVersion)
@@ -128,7 +130,7 @@ class DokkaGenerator(
EnvironmentAndFacade(environment, facade)
}
- private fun translateSources(platformData: PlatformData, context: DokkaContext) =
+ private fun translateSources(platformData: SourceSetData, context: DokkaContext) =
context[CoreExtensions.sourceToDocumentableTranslator].map {
it.invoke(platformData, context)
}
diff --git a/core/src/main/kotlin/configuration.kt b/core/src/main/kotlin/configuration.kt
index 34671c4e..88924924 100644
--- a/core/src/main/kotlin/configuration.kt
+++ b/core/src/main/kotlin/configuration.kt
@@ -1,6 +1,5 @@
package org.jetbrains.dokka
-import org.jetbrains.dokka.pages.PlatformData
import java.io.File
import java.net.URL
@@ -37,8 +36,10 @@ interface DokkaConfiguration {
interface PassConfiguration {
val moduleName: String
+ val sourceSetName: String
val classpath: List<String>
val sourceRoots: List<SourceRoot>
+ val dependentSourceRoots: List<SourceRoot>
val samples: List<String>
val includes: List<String>
val includeNonPublic: Boolean
@@ -59,9 +60,6 @@ interface DokkaConfiguration {
val analysisPlatform: Platform
val targets: List<String>
val sinceKotlin: String?
-
- val platformData: PlatformData
- get() = PlatformData(moduleName, analysisPlatform, targets)
}
interface SourceRoot {
diff --git a/core/src/main/kotlin/defaultConfiguration.kt b/core/src/main/kotlin/defaultConfiguration.kt
index ae674ea1..08f70b45 100644
--- a/core/src/main/kotlin/defaultConfiguration.kt
+++ b/core/src/main/kotlin/defaultConfiguration.kt
@@ -16,8 +16,10 @@ data class DokkaConfigurationImpl(
data class PassConfigurationImpl (
override val moduleName: String,
+ override val sourceSetName: String,
override val classpath: List<String>,
override val sourceRoots: List<SourceRootImpl>,
+ override val dependentSourceRoots: List<SourceRootImpl>,
override val samples: List<String>,
override val includes: List<String>,
override val includeNonPublic: Boolean,
diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt
index 313f4cd4..85487725 100644
--- a/core/src/main/kotlin/model/Documentable.kt
+++ b/core/src/main/kotlin/model/Documentable.kt
@@ -1,11 +1,12 @@
package org.jetbrains.dokka.model
import com.intellij.psi.PsiNamedElement
+import org.jetbrains.dokka.DokkaConfiguration
+import org.jetbrains.dokka.Platform
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.doc.DocumentationNode
import org.jetbrains.dokka.model.properties.PropertyContainer
import org.jetbrains.dokka.model.properties.WithExtraProperties
-import org.jetbrains.dokka.pages.PlatformData
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.load.kotlin.toSourceElement
@@ -13,8 +14,9 @@ abstract class Documentable {
abstract val name: String?
abstract val dri: DRI
abstract val children: List<Documentable>
- abstract val documentation: PlatformDependent<DocumentationNode>
- abstract val platformData: List<PlatformData>
+ abstract val documentation: SourceSetDependent<DocumentationNode>
+ abstract val sourceSets: List<SourceSetData>
+ abstract val expectPresentInSet: SourceSetData?
override fun toString(): String =
"${javaClass.simpleName}($dri)"
@@ -25,45 +27,10 @@ abstract class Documentable {
override fun hashCode() = dri.hashCode()
}
-data class PlatformDependent<out T>(
- val map: Map<PlatformData, T>,
- val expect: T? = null
-) : Map<PlatformData, T> by map {
- val prevalentValue: T?
- get() = map.values.distinct().singleOrNull()
-
- val allValues: Sequence<T> = sequence {
- expect?.also { yield(it) }
- yieldAll(map.values)
- }
-
- val allEntries: Sequence<Pair<PlatformData?, T>> = sequence {
- expect?.also { yield(null to it) }
- map.forEach { (k, v) -> yield(k to v) }
- }
-
- fun getOrExpect(platform: PlatformData): T? = map[platform] ?: expect
-
- companion object {
- fun <T> empty(): PlatformDependent<T> = PlatformDependent(emptyMap())
-
- fun <T> from(platformData: PlatformData, element: T) = PlatformDependent(mapOf(platformData to element))
-
- @Suppress("UNCHECKED_CAST")
- fun <T> from(pairs: Iterable<Pair<PlatformData?, T>>) =
- PlatformDependent(
- pairs.filter { it.first != null }.toMap() as Map<PlatformData, T>,
- pairs.firstOrNull { it.first == null }?.second
- )
-
- fun <T> from(vararg pairs: Pair<PlatformData?, T>) = from(pairs.asIterable())
-
- fun <T> expectFrom(element: T) = PlatformDependent(map = emptyMap(), expect = element)
- }
-}
+typealias SourceSetDependent<T> = Map<SourceSetData, T>
interface WithExpectActual {
- val sources: PlatformDependent<DocumentableSource>
+ val sources: SourceSetDependent<DocumentableSource>
}
interface WithScope {
@@ -73,7 +40,7 @@ interface WithScope {
}
interface WithVisibility {
- val visibility: PlatformDependent<Visibility>
+ val visibility: SourceSetDependent<Visibility>
}
interface WithType {
@@ -81,7 +48,7 @@ interface WithType {
}
interface WithAbstraction {
- val modifier: PlatformDependent<Modifier>
+ val modifier: SourceSetDependent<Modifier>
}
sealed class Modifier(val name: String)
@@ -112,7 +79,7 @@ interface WithGenerics {
}
interface WithSupertypes {
- val supertypes: PlatformDependent<List<DRI>>
+ val supertypes: SourceSetDependent<List<DRI>>
}
interface Callable : WithVisibility, WithType, WithAbstraction, WithExpectActual {
@@ -124,8 +91,9 @@ sealed class DClasslike : Documentable(), WithScope, WithVisibility, WithExpectA
data class DModule(
override val name: String,
val packages: List<DPackage>,
- override val documentation: PlatformDependent<DocumentationNode>,
- override val platformData: List<PlatformData>,
+ override val documentation: SourceSetDependent<DocumentationNode>,
+ override val expectPresentInSet: SourceSetData? = null,
+ override val sourceSets: List<SourceSetData>,
override val extra: PropertyContainer<DModule> = PropertyContainer.empty()
) : Documentable(), WithExtraProperties<DModule> {
override val dri: DRI = DRI.topLevel
@@ -141,8 +109,9 @@ data class DPackage(
override val properties: List<DProperty>,
override val classlikes: List<DClasslike>,
val typealiases: List<DTypeAlias>,
- override val documentation: PlatformDependent<DocumentationNode>,
- override val platformData: List<PlatformData>,
+ override val documentation: SourceSetDependent<DocumentationNode>,
+ override val expectPresentInSet: SourceSetData? = null,
+ override val sourceSets: List<SourceSetData>,
override val extra: PropertyContainer<DPackage> = PropertyContainer.empty()
) : Documentable(), WithScope, WithExtraProperties<DPackage> {
override val name = dri.packageName.orEmpty()
@@ -159,14 +128,15 @@ data class DClass(
override val functions: List<DFunction>,
override val properties: List<DProperty>,
override val classlikes: List<DClasslike>,
- override val sources: PlatformDependent<DocumentableSource>,
- override val visibility: PlatformDependent<Visibility>,
+ override val sources: SourceSetDependent<DocumentableSource>,
+ override val visibility: SourceSetDependent<Visibility>,
override val companion: DObject?,
override val generics: List<DTypeParameter>,
- override val supertypes: PlatformDependent<List<DRI>>,
- override val documentation: PlatformDependent<DocumentationNode>,
- override val modifier: PlatformDependent<Modifier>,
- override val platformData: List<PlatformData>,
+ override val supertypes: SourceSetDependent<List<DRI>>,
+ override val documentation: SourceSetDependent<DocumentationNode>,
+ override val expectPresentInSet: SourceSetData?,
+ override val modifier: SourceSetDependent<Modifier>,
+ override val sourceSets: List<SourceSetData>,
override val extra: PropertyContainer<DClass> = PropertyContainer.empty()
) : DClasslike(), WithAbstraction, WithCompanion, WithConstructors, WithGenerics, WithSupertypes,
WithExtraProperties<DClass> {
@@ -181,16 +151,17 @@ data class DEnum(
override val dri: DRI,
override val name: String,
val entries: List<DEnumEntry>,
- override val documentation: PlatformDependent<DocumentationNode>,
- override val sources: PlatformDependent<DocumentableSource>,
+ override val documentation: SourceSetDependent<DocumentationNode>,
+ override val expectPresentInSet: SourceSetData?,
+ override val sources: SourceSetDependent<DocumentableSource>,
override val functions: List<DFunction>,
override val properties: List<DProperty>,
override val classlikes: List<DClasslike>,
- override val visibility: PlatformDependent<Visibility>,
+ override val visibility: SourceSetDependent<Visibility>,
override val companion: DObject?,
override val constructors: List<DFunction>,
- override val supertypes: PlatformDependent<List<DRI>>,
- override val platformData: List<PlatformData>,
+ override val supertypes: SourceSetDependent<List<DRI>>,
+ override val sourceSets: List<SourceSetData>,
override val extra: PropertyContainer<DEnum> = PropertyContainer.empty()
) : DClasslike(), WithCompanion, WithConstructors, WithSupertypes, WithExtraProperties<DEnum> {
override val children: List<Documentable>
@@ -202,11 +173,12 @@ data class DEnum(
data class DEnumEntry(
override val dri: DRI,
override val name: String,
- override val documentation: PlatformDependent<DocumentationNode>,
+ override val documentation: SourceSetDependent<DocumentationNode>,
+ override val expectPresentInSet: SourceSetData?,
override val functions: List<DFunction>,
override val properties: List<DProperty>,
override val classlikes: List<DClasslike>,
- override val platformData: List<PlatformData>,
+ override val sourceSets: List<SourceSetData>,
override val extra: PropertyContainer<DEnumEntry> = PropertyContainer.empty()
) : Documentable(), WithScope, WithExtraProperties<DEnumEntry> {
override val children: List<Documentable>
@@ -220,14 +192,15 @@ data class DFunction(
override val name: String,
val isConstructor: Boolean,
val parameters: List<DParameter>,
- override val documentation: PlatformDependent<DocumentationNode>,
- override val sources: PlatformDependent<DocumentableSource>,
- override val visibility: PlatformDependent<Visibility>,
+ override val documentation: SourceSetDependent<DocumentationNode>,
+ override val expectPresentInSet: SourceSetData?,
+ override val sources: SourceSetDependent<DocumentableSource>,
+ override val visibility: SourceSetDependent<Visibility>,
override val type: Bound,
override val generics: List<DTypeParameter>,
override val receiver: DParameter?,
- override val modifier: PlatformDependent<Modifier>,
- override val platformData: List<PlatformData>,
+ override val modifier: SourceSetDependent<Modifier>,
+ override val sourceSets: List<SourceSetData>,
override val extra: PropertyContainer<DFunction> = PropertyContainer.empty()
) : Documentable(), Callable, WithGenerics, WithExtraProperties<DFunction> {
override val children: List<Documentable>
@@ -239,16 +212,17 @@ data class DFunction(
data class DInterface(
override val dri: DRI,
override val name: String,
- override val documentation: PlatformDependent<DocumentationNode>,
- override val sources: PlatformDependent<DocumentableSource>,
+ override val documentation: SourceSetDependent<DocumentationNode>,
+ override val expectPresentInSet: SourceSetData?,
+ override val sources: SourceSetDependent<DocumentableSource>,
override val functions: List<DFunction>,
override val properties: List<DProperty>,
override val classlikes: List<DClasslike>,
- override val visibility: PlatformDependent<Visibility>,
+ override val visibility: SourceSetDependent<Visibility>,
override val companion: DObject?,
override val generics: List<DTypeParameter>,
- override val supertypes: PlatformDependent<List<DRI>>,
- override val platformData: List<PlatformData>,
+ override val supertypes: SourceSetDependent<List<DRI>>,
+ override val sourceSets: List<SourceSetData>,
override val extra: PropertyContainer<DInterface> = PropertyContainer.empty()
) : DClasslike(), WithCompanion, WithGenerics, WithSupertypes, WithExtraProperties<DInterface> {
override val children: List<Documentable>
@@ -260,14 +234,15 @@ data class DInterface(
data class DObject(
override val name: String?,
override val dri: DRI,
- override val documentation: PlatformDependent<DocumentationNode>,
- override val sources: PlatformDependent<DocumentableSource>,
+ override val documentation: SourceSetDependent<DocumentationNode>,
+ override val expectPresentInSet: SourceSetData?,
+ override val sources: SourceSetDependent<DocumentableSource>,
override val functions: List<DFunction>,
override val properties: List<DProperty>,
override val classlikes: List<DClasslike>,
- override val visibility: PlatformDependent<Visibility>,
- override val supertypes: PlatformDependent<List<DRI>>,
- override val platformData: List<PlatformData>,
+ override val visibility: SourceSetDependent<Visibility>,
+ override val supertypes: SourceSetDependent<List<DRI>>,
+ override val sourceSets: List<SourceSetData>,
override val extra: PropertyContainer<DObject> = PropertyContainer.empty()
) : DClasslike(), WithSupertypes, WithExtraProperties<DObject> {
override val children: List<Documentable>
@@ -279,15 +254,16 @@ data class DObject(
data class DAnnotation(
override val name: String,
override val dri: DRI,
- override val documentation: PlatformDependent<DocumentationNode>,
- override val sources: PlatformDependent<DocumentableSource>,
+ override val documentation: SourceSetDependent<DocumentationNode>,
+ override val expectPresentInSet: SourceSetData?,
+ override val sources: SourceSetDependent<DocumentableSource>,
override val functions: List<DFunction>,
override val properties: List<DProperty>,
override val classlikes: List<DClasslike>,
- override val visibility: PlatformDependent<Visibility>,
+ override val visibility: SourceSetDependent<Visibility>,
override val companion: DObject?,
override val constructors: List<DFunction>,
- override val platformData: List<PlatformData>,
+ override val sourceSets: List<SourceSetData>,
override val extra: PropertyContainer<DAnnotation> = PropertyContainer.empty()
) : DClasslike(), WithCompanion, WithConstructors, WithExtraProperties<DAnnotation> {
override val children: List<Documentable>
@@ -299,15 +275,16 @@ data class DAnnotation(
data class DProperty(
override val dri: DRI,
override val name: String,
- override val documentation: PlatformDependent<DocumentationNode>,
- override val sources: PlatformDependent<DocumentableSource>,
- override val visibility: PlatformDependent<Visibility>,
+ override val documentation: SourceSetDependent<DocumentationNode>,
+ override val expectPresentInSet: SourceSetData?,
+ override val sources: SourceSetDependent<DocumentableSource>,
+ override val visibility: SourceSetDependent<Visibility>,
override val type: Bound,
override val receiver: DParameter?,
val setter: DFunction?,
val getter: DFunction?,
- override val modifier: PlatformDependent<Modifier>,
- override val platformData: List<PlatformData>,
+ override val modifier: SourceSetDependent<Modifier>,
+ override val sourceSets: List<SourceSetData>,
override val generics: List<DTypeParameter>,
override val extra: PropertyContainer<DProperty> = PropertyContainer.empty()
) : Documentable(), Callable, WithExtraProperties<DProperty>, WithGenerics {
@@ -321,9 +298,10 @@ data class DProperty(
data class DParameter(
override val dri: DRI,
override val name: String?,
- override val documentation: PlatformDependent<DocumentationNode>,
+ override val documentation: SourceSetDependent<DocumentationNode>,
+ override val expectPresentInSet: SourceSetData?,
val type: Bound,
- override val platformData: List<PlatformData>,
+ override val sourceSets: List<SourceSetData>,
override val extra: PropertyContainer<DParameter> = PropertyContainer.empty()
) : Documentable(), WithExtraProperties<DParameter> {
override val children: List<Nothing>
@@ -335,9 +313,10 @@ data class DParameter(
data class DTypeParameter(
override val dri: DRI,
override val name: String,
- override val documentation: PlatformDependent<DocumentationNode>,
+ override val documentation: SourceSetDependent<DocumentationNode>,
+ override val expectPresentInSet: SourceSetData?,
val bounds: List<Bound>,
- override val platformData: List<PlatformData>,
+ override val sourceSets: List<SourceSetData>,
override val extra: PropertyContainer<DTypeParameter> = PropertyContainer.empty()
) : Documentable(), WithExtraProperties<DTypeParameter> {
override val children: List<Nothing>
@@ -350,10 +329,11 @@ data class DTypeAlias(
override val dri: DRI,
override val name: String,
override val type: Bound,
- val underlyingType: PlatformDependent<Bound>,
- override val visibility: PlatformDependent<Visibility>,
- override val documentation: PlatformDependent<DocumentationNode>,
- override val platformData: List<PlatformData>,
+ val underlyingType: SourceSetDependent<Bound>,
+ override val visibility: SourceSetDependent<Visibility>,
+ override val documentation: SourceSetDependent<DocumentationNode>,
+ override val expectPresentInSet: SourceSetData?,
+ override val sourceSets: List<SourceSetData>,
override val extra: PropertyContainer<DTypeAlias> = PropertyContainer.empty()
) : Documentable(), WithType, WithVisibility, WithExtraProperties<DTypeAlias> {
override val children: List<Nothing>
@@ -417,7 +397,7 @@ sealed class JavaVisibility(name: String) : Visibility(name) {
object Default : JavaVisibility("")
}
-fun <T> PlatformDependent<T>?.orEmpty(): PlatformDependent<T> = this ?: PlatformDependent.empty()
+fun <T> SourceSetDependent<T>?.orEmpty(): SourceSetDependent<T> = this ?: emptyMap()
interface DocumentableSource {
val path: String
@@ -429,4 +409,4 @@ class DescriptorDocumentableSource(val descriptor: DeclarationDescriptor) : Docu
class PsiDocumentableSource(val psi: PsiNamedElement) : DocumentableSource {
override val path = psi.containingFile.virtualFile.path
-}
+} \ No newline at end of file
diff --git a/core/src/main/kotlin/model/SourceSetData.kt b/core/src/main/kotlin/model/SourceSetData.kt
new file mode 100644
index 00000000..8f67f272
--- /dev/null
+++ b/core/src/main/kotlin/model/SourceSetData.kt
@@ -0,0 +1,23 @@
+package org.jetbrains.dokka.model
+
+import org.jetbrains.dokka.DokkaConfiguration
+import org.jetbrains.dokka.Platform
+import org.jetbrains.dokka.plugability.DokkaContext
+
+data class SourceSetData(
+ val moduleName: String,
+ val sourceSetName: String,
+ val platform: Platform,
+ val sourceRoots: List<DokkaConfiguration.SourceRoot> = emptyList()
+)
+
+class SourceSetCache {
+ private val sourceSets = HashMap<String, SourceSetData>()
+
+ fun getSourceSet(pass: DokkaConfiguration.PassConfiguration) =
+ sourceSets.getOrPut("${pass.moduleName}/${pass.sourceSetName}",
+ { SourceSetData(pass.moduleName, pass.sourceSetName, pass.analysisPlatform, pass.sourceRoots) }
+ )
+}
+
+fun DokkaContext.sourceSet(pass: DokkaConfiguration.PassConfiguration) : SourceSetData = sourceSetCache.getSourceSet(pass) \ No newline at end of file
diff --git a/core/src/main/kotlin/model/aditionalExtras.kt b/core/src/main/kotlin/model/aditionalExtras.kt
index 58209939..27ad8a55 100644
--- a/core/src/main/kotlin/model/aditionalExtras.kt
+++ b/core/src/main/kotlin/model/aditionalExtras.kt
@@ -41,13 +41,13 @@ object PrimaryConstructorExtra : ExtraProperty<DFunction>, ExtraProperty.Key<DFu
override val key: ExtraProperty.Key<DFunction, *> = this
}
-data class ActualTypealias(val underlyingType: PlatformDependent<Bound>) : ExtraProperty<DClasslike> {
+data class ActualTypealias(val underlyingType: SourceSetDependent<Bound>) : ExtraProperty<DClasslike> {
companion object : ExtraProperty.Key<DClasslike, ActualTypealias> {
override fun mergeStrategyFor(
left: ActualTypealias,
right: ActualTypealias
) =
- MergeStrategy.Replace(ActualTypealias(PlatformDependent(left.underlyingType + right.underlyingType)))
+ MergeStrategy.Replace(ActualTypealias(left.underlyingType + right.underlyingType))
}
override val key: ExtraProperty.Key<DClasslike, ActualTypealias> = ActualTypealias
diff --git a/core/src/main/kotlin/model/documentableUtils.kt b/core/src/main/kotlin/model/documentableUtils.kt
index 7f946344..b09260ee 100644
--- a/core/src/main/kotlin/model/documentableUtils.kt
+++ b/core/src/main/kotlin/model/documentableUtils.kt
@@ -1,21 +1,18 @@
package org.jetbrains.dokka.model
-import org.jetbrains.dokka.pages.PlatformData
+fun <T> SourceSetDependent<T>.filtered(platformDataList: List<SourceSetData>) = filter { it.key in platformDataList }
+fun SourceSetData?.filtered(platformDataList: List<SourceSetData>) = takeIf { this in platformDataList }
-fun <T> PlatformDependent<T>.filtered(platformDataList: List<PlatformData>) = PlatformDependent(
- map.filter { it.key in platformDataList },
- expect
-)
-
-fun DTypeParameter.filter(filteredData: List<PlatformData>) =
- if (filteredData.containsAll(platformData)) this
+fun DTypeParameter.filter(filteredData: List<SourceSetData>) =
+ if (filteredData.containsAll(sourceSets)) this
else {
- val intersection = filteredData.intersect(platformData).toList()
+ val intersection = filteredData.intersect(sourceSets).toList()
if (intersection.isEmpty()) null
else DTypeParameter(
dri,
name,
documentation.filtered(intersection),
+ expectPresentInSet?.takeIf { intersection.contains(expectPresentInSet) },
bounds,
intersection,
extra
diff --git a/core/src/main/kotlin/pages/ContentNodes.kt b/core/src/main/kotlin/pages/ContentNodes.kt
index 26bcdf77..bb669199 100644
--- a/core/src/main/kotlin/pages/ContentNodes.kt
+++ b/core/src/main/kotlin/pages/ContentNodes.kt
@@ -1,6 +1,7 @@
package org.jetbrains.dokka.pages
import org.jetbrains.dokka.links.DRI
+import org.jetbrains.dokka.model.SourceSetData
import org.jetbrains.dokka.model.properties.PropertyContainer
import org.jetbrains.dokka.model.properties.WithExtraProperties
@@ -10,7 +11,7 @@ data class DCI(val dri: Set<DRI>, val kind: Kind) {
interface ContentNode : WithExtraProperties<ContentNode> {
val dci: DCI
- val platforms: Set<PlatformData>
+ val sourceSets: Set<SourceSetData>
val style: Set<Style>
}
@@ -18,7 +19,7 @@ interface ContentNode : WithExtraProperties<ContentNode> {
data class ContentText(
val text: String,
override val dci: DCI,
- override val platforms: Set<PlatformData>,
+ override val sourceSets: Set<SourceSetData>,
override val style: Set<Style> = emptySet(),
override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
) : ContentNode {
@@ -27,7 +28,7 @@ data class ContentText(
// TODO: Remove
data class ContentBreakLine(
- override val platforms: Set<PlatformData>,
+ override val sourceSets: Set<SourceSetData>,
override val dci: DCI = DCI(emptySet(), ContentKind.Empty),
override val style: Set<Style> = emptySet(),
override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
@@ -40,11 +41,11 @@ data class ContentHeader(
override val children: List<ContentNode>,
val level: Int,
override val dci: DCI,
- override val platforms: Set<PlatformData>,
+ override val sourceSets: Set<SourceSetData>,
override val style: Set<Style>,
override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
) : ContentComposite {
- constructor(level: Int, c: ContentComposite) : this(c.children, level, c.dci, c.platforms, c.style, c.extra)
+ constructor(level: Int, c: ContentComposite) : this(c.children, level, c.dci, c.sourceSets, c.style, c.extra)
override fun withNewExtras(newExtras: PropertyContainer<ContentNode>): ContentHeader = copy(extra = newExtras)
}
@@ -54,7 +55,7 @@ data class ContentCode(
override val children: List<ContentNode>,
val language: String,
override val dci: DCI,
- override val platforms: Set<PlatformData>,
+ override val sourceSets: Set<SourceSetData>,
override val style: Set<Style>,
override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
) : ContentComposite {
@@ -69,7 +70,7 @@ data class ContentDRILink(
override val children: List<ContentNode>,
val address: DRI,
override val dci: DCI,
- override val platforms: Set<PlatformData>,
+ override val sourceSets: Set<SourceSetData>,
override val style: Set<Style> = emptySet(),
override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
) : ContentLink {
@@ -81,7 +82,7 @@ data class ContentResolvedLink(
override val children: List<ContentNode>,
val address: String,
override val dci: DCI,
- override val platforms: Set<PlatformData>,
+ override val sourceSets: Set<SourceSetData>,
override val style: Set<Style> = emptySet(),
override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
) : ContentLink {
@@ -95,7 +96,7 @@ data class ContentEmbeddedResource(
val address: String,
val altText: String?,
override val dci: DCI,
- override val platforms: Set<PlatformData>,
+ override val sourceSets: Set<SourceSetData>,
override val style: Set<Style> = emptySet(),
override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
) : ContentLink {
@@ -113,7 +114,7 @@ data class ContentTable(
val header: List<ContentGroup>,
override val children: List<ContentGroup>,
override val dci: DCI,
- override val platforms: Set<PlatformData>,
+ override val sourceSets: Set<SourceSetData>,
override val style: Set<Style>,
override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
) : ContentComposite {
@@ -125,7 +126,7 @@ data class ContentList(
override val children: List<ContentNode>,
val ordered: Boolean,
override val dci: DCI,
- override val platforms: Set<PlatformData>,
+ override val sourceSets: Set<SourceSetData>,
override val style: Set<Style>,
override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
) : ContentComposite {
@@ -136,7 +137,7 @@ data class ContentList(
data class ContentGroup(
override val children: List<ContentNode>,
override val dci: DCI,
- override val platforms: Set<PlatformData>,
+ override val sourceSets: Set<SourceSetData>,
override val style: Set<Style>,
override val extra: PropertyContainer<ContentNode> = PropertyContainer.empty()
) : ContentComposite {
@@ -145,7 +146,7 @@ data class ContentGroup(
data class PlatformHintedContent(
val inner: ContentNode,
- override val platforms: Set<PlatformData>
+ override val sourceSets: Set<SourceSetData>
) : ContentComposite {
override val children = listOf(inner)
@@ -171,7 +172,7 @@ interface Kind
enum class ContentKind : Kind {
Comment, Constructors, Functions, Parameters, Properties, Classlikes, Packages, Symbol, Sample, Main, BriefComment,
- Empty, Source, TypeAliases, Cover, Inheritors, PlatformDependantHint;
+ Empty, Source, TypeAliases, Cover, Inheritors, SourceSetDependantHint;
companion object {
private val platformTagged =
diff --git a/core/src/main/kotlin/pages/PageNodes.kt b/core/src/main/kotlin/pages/PageNodes.kt
index 244d951e..32b2846e 100644
--- a/core/src/main/kotlin/pages/PageNodes.kt
+++ b/core/src/main/kotlin/pages/PageNodes.kt
@@ -1,5 +1,6 @@
package org.jetbrains.dokka.pages
+import org.jetbrains.dokka.DokkaConfiguration
import org.jetbrains.dokka.model.Documentable
import org.jetbrains.dokka.Platform
import org.jetbrains.dokka.links.DRI
@@ -151,10 +152,6 @@ class MemberPageNode(
else MemberPageNode(name, content, dri, documentable, children, embeddedResources)
}
-data class PlatformData(val name: String, val platformType: Platform, val targets: List<String>) {
- override fun toString() = targets.toString()
-}
-
fun PageNode.dfs(predicate: (PageNode) -> Boolean): PageNode? = if (predicate(this)) {
this
} else {
diff --git a/core/src/main/kotlin/plugability/DokkaContext.kt b/core/src/main/kotlin/plugability/DokkaContext.kt
index cefcd286..692803dd 100644
--- a/core/src/main/kotlin/plugability/DokkaContext.kt
+++ b/core/src/main/kotlin/plugability/DokkaContext.kt
@@ -2,7 +2,8 @@ package org.jetbrains.dokka.plugability
import org.jetbrains.dokka.DokkaConfiguration
import org.jetbrains.dokka.EnvironmentAndFacade
-import org.jetbrains.dokka.pages.PlatformData
+import org.jetbrains.dokka.model.SourceSetCache
+import org.jetbrains.dokka.model.SourceSetData
import org.jetbrains.dokka.utilities.DokkaLogger
import java.io.File
import java.net.URLClassLoader
@@ -19,9 +20,10 @@ interface DokkaContext {
fun <T, E> single(point: E): T where T : Any, E : ExtensionPoint<T>
+ val sourceSetCache: SourceSetCache
val logger: DokkaLogger
val configuration: DokkaConfiguration
- val platforms: Map<PlatformData, EnvironmentAndFacade>
+ val platforms: Map<SourceSetData, EnvironmentAndFacade>
val unusedPoints: Collection<ExtensionPoint<*>>
@@ -29,10 +31,11 @@ interface DokkaContext {
fun create(
configuration: DokkaConfiguration,
logger: DokkaLogger,
- platforms: Map<PlatformData, EnvironmentAndFacade>,
+ sourceSets: Map<SourceSetData, EnvironmentAndFacade>,
+ sourceSetsCache: SourceSetCache,
pluginOverrides: List<DokkaPlugin>
): DokkaContext =
- DokkaContextConfigurationImpl(logger, configuration, platforms).apply {
+ DokkaContextConfigurationImpl(logger, configuration, sourceSets, sourceSetsCache).apply {
// File(it.path) is a workaround for an incorrect filesystem in a File instance returned by Gradle.
configuration.pluginsClasspath.map { File(it.path).toURI().toURL() }
.toTypedArray()
@@ -56,7 +59,8 @@ interface DokkaContextConfiguration {
private class DokkaContextConfigurationImpl(
override val logger: DokkaLogger,
override val configuration: DokkaConfiguration,
- override val platforms: Map<PlatformData, EnvironmentAndFacade>
+ override val platforms: Map<SourceSetData, EnvironmentAndFacade>,
+ override val sourceSetCache: SourceSetCache
) : DokkaContext, DokkaContextConfiguration {
private val plugins = mutableMapOf<KClass<*>, DokkaPlugin>()
private val pluginStubs = mutableMapOf<KClass<*>, DokkaPlugin>()
diff --git a/core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt b/core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt
index dfb1f26b..b67a1d57 100644
--- a/core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt
+++ b/core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt
@@ -4,5 +4,5 @@ import org.jetbrains.dokka.model.DModule
import org.jetbrains.dokka.plugability.DokkaContext
interface PreMergeDocumentableTransformer {
- operator fun invoke(modules: List<DModule>, context: DokkaContext): List<DModule>
+ operator fun invoke(modules: List<DModule>): List<DModule>
} \ No newline at end of file
diff --git a/core/src/main/kotlin/transformers/sources/SourceToDocumentableTranslator.kt b/core/src/main/kotlin/transformers/sources/SourceToDocumentableTranslator.kt
index a138b3e2..f9c0a3d0 100644
--- a/core/src/main/kotlin/transformers/sources/SourceToDocumentableTranslator.kt
+++ b/core/src/main/kotlin/transformers/sources/SourceToDocumentableTranslator.kt
@@ -1,9 +1,9 @@
package org.jetbrains.dokka.transformers.sources
import org.jetbrains.dokka.model.DModule
-import org.jetbrains.dokka.pages.PlatformData
+import org.jetbrains.dokka.model.SourceSetData
import org.jetbrains.dokka.plugability.DokkaContext
interface SourceToDocumentableTranslator {
- fun invoke(platformData: PlatformData, context: DokkaContext): DModule
+ fun invoke(sourceSet: SourceSetData, context: DokkaContext): DModule
} \ No newline at end of file