aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src')
-rw-r--r--plugins/base/src/main/kotlin/transformers/documentables/ReportUndocumentedTransformer.kt16
-rw-r--r--plugins/base/src/test/kotlin/transformers/ReportUndocumentedTransformerTest.kt60
2 files changed, 68 insertions, 8 deletions
diff --git a/plugins/base/src/main/kotlin/transformers/documentables/ReportUndocumentedTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/ReportUndocumentedTransformer.kt
index d33b41bf..31d1d241 100644
--- a/plugins/base/src/main/kotlin/transformers/documentables/ReportUndocumentedTransformer.kt
+++ b/plugins/base/src/main/kotlin/transformers/documentables/ReportUndocumentedTransformer.kt
@@ -90,17 +90,21 @@ internal class ReportUndocumentedTransformer : DocumentableTransformer {
private fun isUndocumented(documentable: Documentable, sourceSet: SourceSetData): Boolean {
fun resolveDependentSourceSets(sourceSet: SourceSetData): List<SourceSetData> {
- return sourceSet.dependentSourceSets.map { sourceSetName ->
- documentable.sourceSets.single { it.sourceSetID == sourceSetName }
+ return sourceSet.dependentSourceSets.mapNotNull { sourceSetID ->
+ documentable.sourceSets.singleOrNull { it.sourceSetID == sourceSetID }
}
}
- fun flatDependentSourceSetsTree(sourceSet: SourceSetData): List<SourceSetData> {
- return listOf(sourceSet) + resolveDependentSourceSets(sourceSet)
- .flatMap { resolveDependentSourceSets -> flatDependentSourceSetsTree(resolveDependentSourceSets) }
+ fun withAllDependentSourceSets(sourceSet: SourceSetData): Sequence<SourceSetData> {
+ return sequence {
+ yield(sourceSet)
+ for (dependentSourceSet in resolveDependentSourceSets(sourceSet)) {
+ yieldAll(withAllDependentSourceSets(dependentSourceSet))
+ }
+ }
}
- return flatDependentSourceSetsTree(sourceSet).all { sourceSetOrDependentSourceSet ->
+ return withAllDependentSourceSets(sourceSet).all { sourceSetOrDependentSourceSet ->
documentable.documentation[sourceSetOrDependentSourceSet]?.children?.isEmpty() ?: true
}
}
diff --git a/plugins/base/src/test/kotlin/transformers/ReportUndocumentedTransformerTest.kt b/plugins/base/src/test/kotlin/transformers/ReportUndocumentedTransformerTest.kt
index f05abb1a..5be60109 100644
--- a/plugins/base/src/test/kotlin/transformers/ReportUndocumentedTransformerTest.kt
+++ b/plugins/base/src/test/kotlin/transformers/ReportUndocumentedTransformerTest.kt
@@ -537,6 +537,63 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() {
}
@Test
+ fun `multiplatform undocumented function gets reported`() {
+ val configuration = dokkaConfiguration {
+ passes {
+ pass {
+ reportUndocumented = true
+ analysisPlatform = Platform.common.toString()
+ sourceSetID = "commonMain"
+ displayName = "commonMain"
+ sourceRoots = listOf("src/commonMain/kotlin")
+ }
+
+ pass {
+ reportUndocumented = true
+ analysisPlatform = Platform.jvm.toString()
+ sourceSetID = "jvmMain"
+ displayName = "jvmMain"
+ sourceRoots = listOf("src/jvmMain/kotlin")
+ dependentSourceSets = listOf("commonMain")
+ }
+
+ pass {
+ reportUndocumented = true
+ analysisPlatform = Platform.native.toString()
+ sourceSetID = "macosMain"
+ displayName = "macosMain"
+ sourceRoots = listOf("src/macosMain/kotlin")
+ dependentSourceSets = listOf("commonMain")
+ }
+ }
+ }
+
+ testInline(
+ """
+ |/src/commonMain/kotlin/sample/Common.kt
+ |package sample
+ |expect fun x()
+ |
+ |/src/macosMain/kotlin/sample/MacosMain.kt
+ |package sample
+ |/** Documented */
+ |actual fun x() = Unit
+ |
+ |/src/jvmMain/kotlin/sample/JvmMain.kt
+ |package sample
+ |actual fun x() = Unit
+ """.trimIndent(),
+ configuration
+ ) {
+ pagesTransformationStage = {
+ assertNumberOfUndocumentedReports(2)
+ assertSingleUndocumentedReport(Regex("x.*commonMain"))
+ assertSingleUndocumentedReport(Regex("x.*jvmMain"))
+ }
+ }
+ }
+
+ @Test
fun `java undocumented class gets reported`() {
val configuration = dokkaConfiguration {
passes {
@@ -830,5 +887,4 @@ class ReportUndocumentedTransformerTest : AbstractCoreTest() {
skipDeprecated = skipDeprecated,
suppress = suppress
)
-
-} \ No newline at end of file
+}