forked from JetBrains/kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Dokka filter to suppress java collection functions
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
...in/org/jetbrains/dokka/kotlinlang/JavaCollectionFunctionsDocumentableFilterTransformer.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,37 @@ | ||
/* | ||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. | ||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. | ||
*/ | ||
|
||
package org.jetbrains.dokka.kotlinlang | ||
|
||
import org.jetbrains.dokka.base.transformers.documentables.SuppressedByConditionDocumentableFilterTransformer | ||
import org.jetbrains.dokka.model.DFunction | ||
import org.jetbrains.dokka.model.Documentable | ||
import org.jetbrains.dokka.plugability.DokkaContext | ||
|
||
/** | ||
* Suppress some methods inherited from [java.util.Collection]: | ||
* - The old StdLib doesn't contain them | ||
* - Source code of [kotlin.collections.Collection] and other classes of (Java mapping)[https://kotlinlang.org/docs/java-interop.html#mapped-types] | ||
* don't have them, although these methods can be called | ||
*/ | ||
class JavaCollectionFunctionsDocumentableFilterTransformer(context: DokkaContext) : | ||
SuppressedByConditionDocumentableFilterTransformer(context) { | ||
data class FullyQualifiedMethodName( | ||
val packageName: String, val classNames: String, val methodName: String | ||
) | ||
|
||
private val methodNames = listOf( | ||
FullyQualifiedMethodName("kotlin.collections", "Collection", "stream"), | ||
FullyQualifiedMethodName("kotlin.collections", "Collection", "parallelStream"), | ||
FullyQualifiedMethodName("kotlin.collections", "Collection", "spliterator"), | ||
FullyQualifiedMethodName("kotlin.collections", "Collection", "toArray"), | ||
FullyQualifiedMethodName("kotlin.collections", "Iterable", "forEach"), | ||
FullyQualifiedMethodName("kotlin.collections", "MutableCollection", "removeIf") | ||
) | ||
|
||
override fun shouldBeSuppressed(d: Documentable): Boolean = d is DFunction && methodNames.firstOrNull { | ||
it.packageName == d.dri.packageName && it.classNames == d.dri.classNames && it.methodName == d.dri.callable?.name | ||
} != null | ||
} |
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