-
Notifications
You must be signed in to change notification settings - Fork 391
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ddaafb
commit 441ccc8
Showing
16 changed files
with
242 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...c/main/kotlin/transformers/documentables/InheritedEntriesDocumentableFilterTransformer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.jetbrains.dokka.base.transformers.documentables | ||
|
||
import org.jetbrains.dokka.model.* | ||
import org.jetbrains.dokka.model.properties.WithExtraProperties | ||
import org.jetbrains.dokka.plugability.DokkaContext | ||
|
||
class InheritedEntriesDocumentableFilterTransformer(context: DokkaContext) : | ||
SuppressedByConditionDocumentableFilterTransformer(context) { | ||
override fun shouldBeSuppressed(d: Documentable): Boolean = | ||
context.configuration.suppressInheritedMembers && (d as? WithExtraProperties<Documentable>)?.extra?.get( | ||
InheritedMember | ||
)?.inheritedFrom?.any { entry -> entry.value != null } ?: false | ||
} |
112 changes: 112 additions & 0 deletions
112
...ns/base/src/test/kotlin/transformers/InheritedEntriesDocumentableFilterTransfromerTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package transformers | ||
|
||
import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest | ||
import org.junit.jupiter.api.Test | ||
import kotlin.test.assertEquals | ||
|
||
class InheritedEntriesDocumentableFilterTransformerTest : BaseAbstractTest() { | ||
val suppressingInheritedConfiguration = dokkaConfiguration { | ||
suppressInheritedMembers = true | ||
suppressObviousFunctions = false | ||
sourceSets { | ||
sourceSet { | ||
sourceRoots = listOf("src") | ||
} | ||
} | ||
} | ||
|
||
val nonSuppressingInheritedConfiguration = dokkaConfiguration { | ||
suppressObviousFunctions = false | ||
suppressInheritedMembers = false | ||
sourceSets { | ||
sourceSet { | ||
sourceRoots = listOf("src") | ||
} | ||
} | ||
} | ||
|
||
|
||
@Test | ||
fun `should suppress toString, equals and hashcode but keep custom ones`() { | ||
testInline( | ||
""" | ||
/src/suppressed/Suppressed.kt | ||
package suppressed | ||
data class Suppressed(val x: String) { | ||
override fun toString(): String { | ||
return "custom" | ||
} | ||
} | ||
""".trimIndent(), | ||
suppressingInheritedConfiguration | ||
) { | ||
preMergeDocumentablesTransformationStage = { modules -> | ||
val functions = modules.flatMap { it.packages }.flatMap { it.classlikes }.flatMap { it.functions } | ||
assertEquals(listOf("toString", "copy", "component1").sorted(), functions.map { it.name }.sorted()) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun `should suppress toString, equals and hashcode`() { | ||
testInline( | ||
""" | ||
/src/suppressed/Suppressed.kt | ||
package suppressed | ||
data class Suppressed(val x: String) | ||
""".trimIndent(), | ||
suppressingInheritedConfiguration | ||
) { | ||
preMergeDocumentablesTransformationStage = { modules -> | ||
val functions = modules.flatMap { it.packages }.flatMap { it.classlikes }.flatMap { it.functions } | ||
assertEquals(listOf("copy", "component1").sorted(), functions.map { it.name }.sorted()) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun `should also suppress properites`(){ | ||
testInline( | ||
""" | ||
/src/suppressed/Suppressed.kt | ||
package suppressed | ||
open class Parent { | ||
val parentValue = "String" | ||
} | ||
class Child : Parent { | ||
} | ||
""".trimIndent(), | ||
suppressingInheritedConfiguration | ||
) { | ||
preMergeDocumentablesTransformationStage = { modules -> | ||
val properties = modules.flatMap { it.packages }.flatMap { it.classlikes }.first { it.name == "Child" }.properties | ||
assertEquals(0, properties.size) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun `should not suppress properites if config says so`(){ | ||
testInline( | ||
""" | ||
/src/suppressed/Suppressed.kt | ||
package suppressed | ||
open class Parent { | ||
val parentValue = "String" | ||
} | ||
class Child : Parent { | ||
} | ||
""".trimIndent(), | ||
nonSuppressingInheritedConfiguration | ||
) { | ||
preMergeDocumentablesTransformationStage = { modules -> | ||
val properties = modules.flatMap { it.packages }.flatMap { it.classlikes }.first { it.name == "Child" }.properties | ||
assertEquals(listOf("parentValue"), properties.map { it.name }) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.