Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: stop including playground.js in Dokka pages and correctly filter for internal APIs #1404

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

package aws.sdk.kotlin.dokka

import aws.sdk.kotlin.dokka.transformers.DisablePlaygroundIntegration
import aws.sdk.kotlin.dokka.transformers.FilterInternalApis
import aws.sdk.kotlin.dokka.transformers.NoOpSearchbarDataInstaller
import org.jetbrains.dokka.CoreExtensions
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.plugability.DokkaPlugin
import org.jetbrains.dokka.plugability.DokkaPluginApiPreview
Expand All @@ -32,6 +34,12 @@ class AwsDokkaPlugin : DokkaPlugin() {
dokkaBase.htmlPreprocessors providing ::NoOpSearchbarDataInstaller override dokkaBase.baseSearchbarDataInstaller
}

val disablePlaygroundIntegration by extending {
CoreExtensions.pageTransformer providing ::DisablePlaygroundIntegration order {
after(dokkaBase.defaultSamplesTransformer)
}
}

@DokkaPluginApiPreview
override fun pluginApiPreviewAcknowledgement() = PluginApiPreviewAcknowledgement
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package aws.sdk.kotlin.dokka.transformers

import org.jetbrains.dokka.pages.RootPageNode
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.transformers.pages.PageTransformer

@Suppress("UNUSED_PARAMETER") // `context` is required by the `provides` DSL method for installing transformers
class DisablePlaygroundIntegration(context: DokkaContext) : PageTransformer {
override fun invoke(input: RootPageNode) = input.transformContentPagesTree { page ->
page.modified(
content = page.content,
embeddedResources = page.embeddedResources.filterNot { "unpkg.com" in it },
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ import org.jetbrains.dokka.plugability.DokkaContext
class FilterInternalApis(context: DokkaContext) : SuppressedByConditionDocumentableFilterTransformer(context) {
override fun shouldBeSuppressed(d: Documentable): Boolean {
val isInternal = when (d) {
is DClass -> d.isInternalSdk()
is DObject -> d.isInternalSdk()
is DTypeAlias -> d.isInternalSdk()
is DFunction -> d.isInternalSdk()
is DProperty -> d.isInternalSdk()
is DEnum -> d.isInternalSdk()
is DEnumEntry -> d.isInternalSdk()
is DTypeParameter -> d.isInternalSdk()
is DClass -> d.isInternalSdk
is DObject -> d.isInternalSdk
is DTypeAlias -> d.isInternalSdk
is DFunction -> d.isInternalSdk
is DProperty -> d.isInternalSdk
is DEnum -> d.isInternalSdk
is DEnumEntry -> d.isInternalSdk
is DTypeParameter -> d.isInternalSdk
else -> false
}

Expand All @@ -33,12 +33,12 @@ class FilterInternalApis(context: DokkaContext) : SuppressedByConditionDocumenta
}
}

fun <T> T.isInternalSdk() where T : WithExtraProperties<out Documentable> =
internalAnnotation != null
private val internalAnnotationNames = setOf("InternalApi", "InternalSdkApi")

val <T> T.internalAnnotation where T : WithExtraProperties<out Documentable>
get() = extra[Annotations]?.let { annotations ->
annotations.directAnnotations.values.flatten().firstOrNull {
it.dri.toString() == "aws.sdk.kotlin.runtime/InternalSdkApi///PointingToDeclaration/"
}
}
private val <T> T.isInternalSdk: Boolean where T : WithExtraProperties<out Documentable>
get() = extra[Annotations]
?.directAnnotations
.orEmpty()
.values
.flatten()
.any { it.dri.classNames in internalAnnotationNames }
Loading