Skip to content

Commit

Permalink
tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-enko committed Oct 17, 2024
1 parent 8c81b9b commit 8eb1a64
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dokka {
@OptIn(DokkaInternalApi::class)
abstract class HideInternalApiParameters @Inject constructor(
name: String
) : DokkaPluginParametersBaseSpec(name, "demo.dokka.plugin.ogp.HideInternalApiPlugin") {
) : DokkaPluginParametersBaseSpec(name, "demo.dokka.plugin.HideInternalApiPlugin") {

@get:Input
@get:Optional
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
package demo.dokka.plugin.ogp
/*
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

package demo.dokka.plugin

import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
Expand All @@ -23,24 +27,30 @@ class HideInternalApiPlugin : DokkaPlugin() {
override fun pluginApiPreviewAcknowledgement() = PluginApiPreviewAcknowledgement

companion object {
const val FQN = "demo.dokka.plugin.ogp.HideInternalApiPlugin"
const val FQN = "demo.dokka.plugin.HideInternalApiPlugin"
}
}

/**
* Configuration for [HideInternalApiPlugin].
*/
@Serializable
data class HideInternalApiConfig(
val annotatedWith: List<String>
)

class HideInternalApiTransformer(context: DokkaContext) : SuppressedByConditionDocumentableFilterTransformer(context) {

private val configuration by lazy {
/**
* Decode [HideInternalApiPlugin] from the [DokkaContext].
*/
private val configuration: HideInternalApiPlugin by lazy {
val pluginConfig = context.configuration.pluginsConfiguration
.firstOrNull { it.fqPluginName == HideInternalApiPlugin.FQN }

if (pluginConfig != null) {
require(pluginConfig.serializationFormat == DokkaConfiguration.SerializationFormat.JSON) {
"HideInternalApiPlugin requires configuration is encoded as JSON"
"HideInternalApiPlugin configuration must be encoded as JSON"
}

Json.decodeFromString(HideInternalApiConfig.serializer(), pluginConfig.values)
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
demo.dokka.plugin.ogp.HideInternalApiPlugin
demo.dokka.plugin.HideInternalApiPlugin

0 comments on commit 8eb1a64

Please sign in to comment.