dokka icon indicating copy to clipboard operation
dokka copied to clipboard

Split package (cross module) links not working

Open jgrnrt opened this issue 1 month ago • 4 comments

Question Hello, I am currently working on the mockk project and try to migrate to dokka v2. I've copied your configuration from your multi-module example. I've encountered two problems.

see links and return types from different modules can't be resolved

Is there a simple fix for that? We are creating sourceSets like this:

kotlin {
    jvm()
    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(projects.modules.mockk)
            }
        }
     }
}

Aggregation of android projects are not working

When i run the dokkaGenerate task for each android project they are created.

When i run the dokkaGenerate task in the docs project, the android projects are not generating dokka files in build output. In some is the dokka-module folder missing. In some is dokka-module folder with empty html/module folder and the module-descriptor.json.

Only multiplatform modules can be aggregated into the full html documentation.

Installation

  • Operating system: Linux
  • Build tool: Gradle 9.2.1, Android Gradle plugin 8.13.0
  • Dokka version: 2.1.0

jgrnrt avatar Nov 23 '25 16:11 jgrnrt

Hey! Could you share a branch with your configuration so that I can investigate it?

whyoleg avatar Nov 24 '25 09:11 whyoleg

Thank you for looking into it. This is the branch https://github.com/jgrnrt/mockk/tree/junit-6 . Please ignore tests.

jgrnrt avatar Nov 24 '25 12:11 jgrnrt

Here is what I have found so far. First, regarding unresolved links (based on logs):

  1. [io.mockk.slot] and on other declarations in that file - correctly unresolved, as slot function is declared in mockk project, which is not a dependency of mockk-dsl. This link was previously incorrectly resolved in the IDE, but with K2 in place, it's not resolved in the IDE either.
  2. [io.mockk.junit5.MockKExtension] and in other annotations - correctly unresolved, because it's not allowed to reference from common to jvm source-set.
  3. [io.mockk.every] and some other links in the file - this is unresolved, probably because there is a split package for the io.mockk package, which is both available in the mockk and mockk-dsl projects. The same is most likely happening for [MockKMatcherScope.capture] and return types of functions like slot. Dokka doesn't work correctly when there is a split package. There was an attempt to fix such links in https://github.com/Kotlin/dokka/pull/3425; however, it appears that in cases where the module itself (mockk) has the same package as the module to which functions are referred (mockk-dsl) and vice versa, the fix doesn't work. It requires further investigation to determine if we can support this.

Were those issues present previously, with an earlier Dokka version?


Second, regarding aggregation. Based on the configuration in the docs module:

dependencies {
    dokka(projects.modules.mockk) // works
    dokka(projects.modules.mockkAgent) // works
    dokka(projects.modules.mockkAgentAndroidDispatcher) // empty - no kotlin plugin
    dokka(projects.modules.mockkAgentApi) // works
    dokka(projects.modules.mockkAndroid) // empty - no sources
    dokka(projects.modules.mockkBdd) // work
    dokka(projects.modules.mockkBddAndroid) // empty - no declarations
    dokka(projects.modules.mockkCore) // works
    dokka(projects.modules.mockkDsl) // works
}

I see that the projects, where nothing is generated, are projects without sources or declarations. Only one project, which might be supported, is mockkAgentAndroidDispatcher, for that, you need to add the kotlin plugin there to create corresponding Dokka source sets.

Hope this helps!

whyoleg avatar Nov 27 '25 14:11 whyoleg

I've implemented some fixes:

  • removed incorrect links
  • added missing Unit declarations, which needed to be explicitly typed
  • added kotlin plugin for dispatcher module
  • added a missing android module (which probably confused me in the first place)

I hope you'll be able to support split packages in the future. Until then, I suppose we'll have to accept the error messages for some parameter and return types.

Thank you very much for your support and your well-written explanations.

jgrnrt avatar Nov 30 '25 13:11 jgrnrt