aboutsummaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/kotlin/CoreExtensions.kt2
-rw-r--r--core/src/main/kotlin/DokkaGenerator.kt18
-rw-r--r--core/src/main/kotlin/configuration.kt4
-rw-r--r--core/src/main/kotlin/model/documentableUtils.kt23
-rw-r--r--core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt8
5 files changed, 50 insertions, 5 deletions
diff --git a/core/src/main/kotlin/CoreExtensions.kt b/core/src/main/kotlin/CoreExtensions.kt
index be354bc4..d7b0b285 100644
--- a/core/src/main/kotlin/CoreExtensions.kt
+++ b/core/src/main/kotlin/CoreExtensions.kt
@@ -6,6 +6,7 @@ import org.jetbrains.dokka.transformers.descriptors.DescriptorToDocumentableTran
import org.jetbrains.dokka.transformers.documentation.DocumentableMerger
import org.jetbrains.dokka.transformers.documentation.DocumentableToPageTranslator
import org.jetbrains.dokka.transformers.documentation.DocumentableTransformer
+import org.jetbrains.dokka.transformers.documentation.PreMergeDocumentableTransformer
import org.jetbrains.dokka.transformers.pages.PageTransformer
import org.jetbrains.dokka.transformers.psi.PsiToDocumentableTranslator
import kotlin.reflect.KProperty
@@ -13,6 +14,7 @@ import kotlin.reflect.KProperty
object CoreExtensions {
val descriptorToDocumentableTranslator by coreExtension<DescriptorToDocumentableTranslator>()
val psiToDocumentableTranslator by coreExtension<PsiToDocumentableTranslator>()
+ val preMergeDocumentableTransformer by coreExtension<PreMergeDocumentableTransformer>()
val documentableMerger by coreExtension<DocumentableMerger>()
val documentableTransformer by coreExtension<DocumentableTransformer>()
val documentableToPageTranslator by coreExtension<DocumentableToPageTranslator>()
diff --git a/core/src/main/kotlin/DokkaGenerator.kt b/core/src/main/kotlin/DokkaGenerator.kt
index a260d5ad..d598c773 100644
--- a/core/src/main/kotlin/DokkaGenerator.kt
+++ b/core/src/main/kotlin/DokkaGenerator.kt
@@ -39,11 +39,14 @@ class DokkaGenerator(
report("Creating documentation models")
val modulesFromPlatforms = createDocumentationModels(platforms, context)
+ report("Transforming documentation model before merging")
+ val transformedDocumentationBeforeMerge = transformDocumentationModelBeforeMerge(modulesFromPlatforms, context)
+
report("Merging documentation models")
- val documentationModel = mergeDocumentationModels(modulesFromPlatforms, context)
+ val documentationModel = mergeDocumentationModels(transformedDocumentationBeforeMerge, context)
- report("Transforming documentation model")
- val transformedDocumentation = transformDocumentationModel(documentationModel, context)
+ report("Transforming documentation model after merging")
+ val transformedDocumentation = transformDocumentationModelAfterMerge(documentationModel, context)
report("Creating pages")
val pages = createPages(transformedDocumentation, context)
@@ -61,7 +64,7 @@ class DokkaGenerator(
fun setUpAnalysis(configuration: DokkaConfiguration): Map<PlatformData, EnvironmentAndFacade> =
configuration.passesConfigurations.map {
- PlatformData(it.moduleName, it.analysisPlatform, it.targets) to createEnvironmentAndFacade(it)
+ it.platformData to createEnvironmentAndFacade(it)
}.toMap()
fun initializePlugins(
@@ -77,12 +80,17 @@ class DokkaGenerator(
) = platforms.map { (pdata, _) -> translateDescriptors(pdata, context) } +
platforms.map { (pdata, _) -> translatePsi(pdata, context) }
+ fun transformDocumentationModelBeforeMerge(
+ modulesFromPlatforms: List<DModule>,
+ context: DokkaContext
+ ) = context[CoreExtensions.preMergeDocumentableTransformer].fold(modulesFromPlatforms) { acc, t -> t(acc, context) }
+
fun mergeDocumentationModels(
modulesFromPlatforms: List<DModule>,
context: DokkaContext
) = context.single(CoreExtensions.documentableMerger).invoke(modulesFromPlatforms, context)
- fun transformDocumentationModel(
+ fun transformDocumentationModelAfterMerge(
documentationModel: DModule,
context: DokkaContext
) = context[CoreExtensions.documentableTransformer].fold(documentationModel) { acc, t -> t(acc, context) }
diff --git a/core/src/main/kotlin/configuration.kt b/core/src/main/kotlin/configuration.kt
index 8c6d35e8..4a6b7d68 100644
--- a/core/src/main/kotlin/configuration.kt
+++ b/core/src/main/kotlin/configuration.kt
@@ -1,5 +1,6 @@
package org.jetbrains.dokka
+import org.jetbrains.dokka.pages.PlatformData
import java.io.File
import java.net.URL
@@ -57,6 +58,9 @@ 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/model/documentableUtils.kt b/core/src/main/kotlin/model/documentableUtils.kt
new file mode 100644
index 00000000..7f946344
--- /dev/null
+++ b/core/src/main/kotlin/model/documentableUtils.kt
@@ -0,0 +1,23 @@
+package org.jetbrains.dokka.model
+
+import org.jetbrains.dokka.pages.PlatformData
+
+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
+ else {
+ val intersection = filteredData.intersect(platformData).toList()
+ if (intersection.isEmpty()) null
+ else DTypeParameter(
+ dri,
+ name,
+ documentation.filtered(intersection),
+ bounds,
+ intersection,
+ extra
+ )
+ } \ No newline at end of file
diff --git a/core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt b/core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt
new file mode 100644
index 00000000..dfb1f26b
--- /dev/null
+++ b/core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt
@@ -0,0 +1,8 @@
+package org.jetbrains.dokka.transformers.documentation
+
+import org.jetbrains.dokka.model.DModule
+import org.jetbrains.dokka.plugability.DokkaContext
+
+interface PreMergeDocumentableTransformer {
+ operator fun invoke(modules: List<DModule>, context: DokkaContext): List<DModule>
+} \ No newline at end of file