diff options
author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2022-07-08 15:14:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-08 15:14:48 +0200 |
commit | 393491918eb31fd1896c747e636965f917754b1b (patch) | |
tree | e04ceff74b3b6abd3619dd29eabcf0da44f2432f /examples/plugin/hide-internal-api/src/main/kotlin/org | |
parent | 3ee4fd840a93d976631535450f9b9402b3c89af8 (diff) | |
download | dokka-393491918eb31fd1896c747e636965f917754b1b.tar.gz dokka-393491918eb31fd1896c747e636965f917754b1b.tar.bz2 dokka-393491918eb31fd1896c747e636965f917754b1b.zip |
Revise developer guides documentation (#2523)
Diffstat (limited to 'examples/plugin/hide-internal-api/src/main/kotlin/org')
-rw-r--r-- | examples/plugin/hide-internal-api/src/main/kotlin/org/example/dokka/plugin/HideInternalApiPlugin.kt | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/examples/plugin/hide-internal-api/src/main/kotlin/org/example/dokka/plugin/HideInternalApiPlugin.kt b/examples/plugin/hide-internal-api/src/main/kotlin/org/example/dokka/plugin/HideInternalApiPlugin.kt new file mode 100644 index 00000000..e0edac4b --- /dev/null +++ b/examples/plugin/hide-internal-api/src/main/kotlin/org/example/dokka/plugin/HideInternalApiPlugin.kt @@ -0,0 +1,34 @@ +package org.example.dokka.plugin + +import org.jetbrains.dokka.base.DokkaBase +import org.jetbrains.dokka.base.transformers.documentables.SuppressedByConditionDocumentableFilterTransformer +import org.jetbrains.dokka.model.Annotations +import org.jetbrains.dokka.model.Documentable +import org.jetbrains.dokka.model.properties.WithExtraProperties +import org.jetbrains.dokka.plugability.DokkaContext +import org.jetbrains.dokka.plugability.DokkaPlugin + +class HideInternalApiPlugin : DokkaPlugin() { + val myFilterExtension by extending { + plugin<DokkaBase>().preMergeDocumentableTransformer providing ::HideInternalApiTransformer + } +} + +class HideInternalApiTransformer(context: DokkaContext) : SuppressedByConditionDocumentableFilterTransformer(context) { + + override fun shouldBeSuppressed(d: Documentable): Boolean { + val annotations: List<Annotations.Annotation> = + (d as? WithExtraProperties<*>) + ?.extra + ?.allOfType<Annotations>() + ?.flatMap { it.directAnnotations.values.flatten() } + ?: emptyList() + + return annotations.any { isInternalAnnotation(it) } + } + + private fun isInternalAnnotation(annotation: Annotations.Annotation): Boolean { + return annotation.dri.packageName == "org.jetbrains.dokka.internal.test" + && annotation.dri.classNames == "Internal" + } +} |