dokka icon indicating copy to clipboard operation
dokka copied to clipboard

Dokka 2+: Creating a custom format requires access to an internal configuration

Open CLOVIS-AI opened this issue 1 year ago • 7 comments
trafficstars

Is your feature request related to a problem? Please describe

I am creating a custom Dokka output format. More specifically, I'm embedding Dokka into an MkDocs website.

Since I created a custom format, Dokka generates a task that creates all the files. But I need them to be in a specific directory. I want to recursively access all generated files.

At the moment, the best way to do so seems to be to declare a dependency on the configuration dokkaMkdocsModuleOutputDirectoriesResolver~internal, which I do here and is used in the Sync task declared just below.

Describe the solution you'd like

A way to access all the files that were outputted by my custom format, across any project registered in the current project through dependencies { dokka(…) }.

Describe alternatives you've considered

I don't know what's possible here.

CLOVIS-AI avatar Nov 15 '24 19:11 CLOVIS-AI

Hi, thanks for the request.

I see the difficulty, and while I don't have the time right now to have a thorough look, I have a suggestion: Could you try accessing the files from the DokkaFormatPluginContext instead?

abstract class DokkaMkDocsPlugin : DokkaFormatPlugin(formatName = "mkdocs") {

    @OptIn(DokkaInternalApi::class)
    override fun DokkaFormatPluginContext.configure() {
        val moduleOutputFiles = formatDependencies.moduleOutputDirectories.incomingArtifactFiles

        // ...
    }

    // ...
}

adam-enko avatar Nov 19 '24 12:11 adam-enko

DokkaFormatPlugin doesn't seem to have a configure method that I can override? I'm a bit confused

CLOVIS-AI avatar Dec 11 '24 20:12 CLOVIS-AI

DokkaFormatPlugin doesn't seem to have a configure method that I can override? I'm a bit confused

Hmm strange, it should be there, both in Dokka and Dokkatoo

  • https://github.com/Kotlin/dokka/blob/a2fe93492409054bdc754ef6b935f4e2f00ca4f1/dokka-runners/dokka-gradle-plugin/src/main/kotlin/formats/DokkaFormatPlugin.kt#L147-L148
  • https://github.com/adamko-dev/dokkatoo/blob/07c697e0b3864110ddeedec761089b2d4aa49e87/modules/dokkatoo-plugin/src/main/kotlin/formats/DokkatooFormatPlugin.kt#L144-L145

Could you share more info? Do you get an error message?

adam-enko avatar Dec 12 '24 08:12 adam-enko

Weird. Just IDEA that says there is no method to override. I tried to copy-paste your snippet in this file, I don't know where else it could be?

CLOVIS-AI avatar Dec 12 '24 09:12 CLOVIS-AI

I see the method is already overridden https://gitlab.com/opensavvy/automation/dokka-material-mkdocs/-/blob/main/dokka-mkdocs/src/main/kotlin/DokkaMkDocsPlugin.kt?ref_type=heads#L118-123, so I guess it's a very unhelpful error message from IJ?

adam-enko avatar Dec 12 '24 09:12 adam-enko

uh, I'm dumb. Thanks, I'll try it again then :|

CLOVIS-AI avatar Dec 12 '24 11:12 CLOVIS-AI

I've removed this from the 2.1.0 milestone because we want to focus on releasing DGPv2 as default, and this issue has a workaround (opt-in to DokkaInternalApi).

adam-enko avatar Jun 05 '25 14:06 adam-enko