aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-08-11 12:52:43 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-08-12 09:38:06 +0200
commitbbe5b00387da8fb8a54f8a8ecd80f2f2dea06830 (patch)
tree193349416ab229be3aafe6b9801c1afe66b8b116 /core
parent6a7d1c9aedfb12f309a410c404a830cb9d3972d3 (diff)
downloaddokka-bbe5b00387da8fb8a54f8a8ecd80f2f2dea06830.tar.gz
dokka-bbe5b00387da8fb8a54f8a8ecd80f2f2dea06830.tar.bz2
dokka-bbe5b00387da8fb8a54f8a8ecd80f2f2dea06830.zip
Move utility APIs into `PreMergeDocumentationTransformer`
Diffstat (limited to 'core')
-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])
+}