I want to create a plantuml plugin for Dokka to wr...
# dokka
h
I want to create a plantuml plugin for Dokka to write plantuml code in included Markdown files that will be converted to a png file and added to Dokka html output in the place of the plantuml code. Do you have any entry points how to get the ContentCodeBlock and how to replace it with a link to a png file? I don't want to support plantuml in Kdoc, Module markdown file is enough (for the first step).
✅ 1
This is my current (non working) code:
Copy code
public class PlantumlPlugin : DokkaPlugin() {

    public val pageTransformer: Extension<PageTransformer, *, *> by extending {
        CoreExtensions.pageTransformer with PlantumlPageTransformer
    }

    @OptIn(DokkaPluginApiPreview::class)
    override fun pluginApiPreviewAcknowledgement(): PluginApiPreviewAcknowledgement =
        PluginApiPreviewAcknowledgement
}

public data object PlantumlPageTransformer : PageTransformer {

    override fun invoke(input: RootPageNode): RootPageNode =
        input.transformContentPagesTree { page ->

            val generated = mutableMapOf<String, String>()

            val content = page.content.recursiveMapTransform<ContentNode, ContentNode> { node ->
                if (
                    node !is ContentCodeBlock ||
                    !node.language.equals("plantuml", ignoreCase = true)
                ) {
                    return@recursiveMapTransform node
                }

                val source = node.children
                    .filterIsInstance<ContentText>()
                    .joinToString("") { it.text }

                val resource = generated.getOrPut(source) {
                    render(source)
                }

                ContentEmbeddedResource(
                    address = resource,
                    altText = "PlantUML diagram",
                    dci = node.dci,
                    sourceSets = node.sourceSets,
                    style = node.style,
                    extra = node.extra
                )
            }

            page.modified(
                content = content,
                embeddedResources =
                    page.embeddedResources + generated.values
            )
        }
}
I managed to get it to work: https://github.com/hfhbd/dokka-plantuml