aboutsummaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/kotlin/model/Documentable.kt2
-rw-r--r--core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt26
2 files changed, 25 insertions, 3 deletions
diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt
index 4f9732c0..3f91e3cb 100644
--- a/core/src/main/kotlin/model/Documentable.kt
+++ b/core/src/main/kotlin/model/Documentable.kt
@@ -113,7 +113,7 @@ data class DPackage(
) : Documentable(), WithScope, WithExtraProperties<DPackage> {
override val name = dri.packageName.orEmpty()
override val children: List<Documentable>
- get() = (properties + functions + classlikes)
+ get() = (properties + functions + classlikes + typealiases)
override fun withNewExtras(newExtras: PropertyContainer<DPackage>) = copy(extra = newExtras)
}
diff --git a/core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt b/core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt
index b67a1d57..dfc7319f 100644
--- a/core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt
+++ b/core/src/main/kotlin/transformers/documentation/PreMergeDocumentableTransformer.kt
@@ -1,8 +1,30 @@
package org.jetbrains.dokka.transformers.documentation
+import org.jetbrains.dokka.DokkaConfiguration
+import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet
import org.jetbrains.dokka.model.DModule
-import org.jetbrains.dokka.plugability.DokkaContext
+import org.jetbrains.dokka.model.Documentable
+import org.jetbrains.dokka.model.DocumentableSource
+import org.jetbrains.dokka.model.WithExpectActual
interface PreMergeDocumentableTransformer {
operator fun invoke(modules: List<DModule>): List<DModule>
-} \ No newline at end of file
+
+ /* Convenience functions */
+ /**
+ * A [PreMergeDocumentableTransformer] can safely assume that documentables are not merged and therefore
+ * only belong to a single source set
+ */
+ val Documentable.sourceSet: DokkaSourceSet get() = sourceSets.single()
+
+ val Documentable.perPackageOptions: DokkaConfiguration.PackageOptions?
+ get() {
+ val packageName = dri.packageName ?: return null
+ return sourceSet.perPackageOptions
+ .sortedByDescending { packageOptions -> packageOptions.prefix.length }
+ .firstOrNull { packageOptions -> packageName.startsWith(packageOptions.prefix) }
+ }
+
+ val <T> T.source: DocumentableSource where T : Documentable, T : WithExpectActual
+ get() = checkNotNull(sources[sourceSet])
+}