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

Dokka GP v2 excludes the local module if submodules are added as dependencies #3979

Open
DanySK opened this issue Dec 29, 2024 · 0 comments
Open
Labels

Comments

@DanySK
Copy link

DanySK commented Dec 29, 2024

Describe the bug

I have a project with many subproject. The root project hosts the entrypoint of the entire application.
When generating documentation for the root project, if no subproject is added through dependency, only the local module's documentation is produced (as expected).
When, instead,

dependencies {
    subprojects.forEach { dokka(it) }
}

is used, the documentation for all modules but the current is produced.

If

dependencies {
    allprojects.forEach { dokka(it) }
}

is used instead, the local module is included, but the left menu has broken links

Expected behaviour

Either the local module is always included, or it can be included in the dependencies without breaking the website

Screenshots

This is the documentation generated with

dependencies {
    allprojects.forEach { dokka(it) }
}

Peek 2024-12-29 23-21

Links on the right work correctly, links in the left bar are broken.

To Reproduce

  1. Create a mutlimodule project
  2. Apply dokka
  3. add sources to the root project and to the subprojects
  4. Enable dokka v2
  5. run dokkaGenerate

Dokka configuration

The following is my convention plugin for dokka. Looks complicated , but all the complexity is just linking source from GitHub and linking libraries from javadoc.io.

import Util.currentCommitHash
import Util.fetchJavadocIOForDependency
import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask
import org.jetbrains.dokka.gradle.tasks.DokkaBaseTask
import java.time.Duration

/*
 * Copyright (C) 2010-2024, Danilo Pianini and contributors
 * listed, for each module, in the respective subproject's build.gradle.kts file.
 *
 * This file is part of Alchemist, and is distributed under the terms of the
 * GNU General Public License, with a linking exception,
 * as described in the file LICENSE in the Alchemist distribution's top directory.
 */
plugins {
    id("org.jetbrains.dokka")
}

val minJavaVersion: String by properties

dokka {
    dokkaSourceSets.configureEach {
        enableKotlinStdLibDocumentationLink.set(true)
        enableJdkDocumentationLink.set(true)
        jdkVersion.set(minJavaVersion.toInt())
        skipDeprecated.set(false)
        skipEmptyPackages.set(true)
        /*
         * Source links to GitHub
         */
        listOf("kotlin", "java")
            .flatMap { listOf("main/$it", "commonMain/$it", "jsMain/$it", "jvmMain/$it") }
            .map { "src/$it" }
            .associateWith { File(projectDir, it) }
            .filterValues { it.exists() }
            .forEach { (path, file) ->
                sourceLink {
                    localDirectory.set(file)
                    val project = if (project == rootProject) "" else project.name
                    val url = "https://github.com/AlchemistSimulator/Alchemist/${
                        currentCommitHash?.let { "tree/$it" } ?: "blob/master"
                    }/$project/$path"
                    remoteUrl.set(uri(url))
                    remoteLineSuffix.set("#L")
                }
            }
        /*
         * Javadoc.io links for external dependencies
         */
        val configured = mutableSetOf<ExternalDependency>()
        configurations.configureEach {
            val newDependencies = dependencies.withType<ExternalDependency>() - configured
            configured += newDependencies
            newDependencies.forEach { dependency ->
                val javadocIOURLs = fetchJavadocIOForDependency(dependency)
                if (javadocIOURLs != null) {
                    val (javadoc, packageList) = javadocIOURLs
                    externalDocumentationLinks.register(dependency.name) {
                        url.set(javadoc)
                        packageListUrl.set(packageList)
                    }
                }
            }
        }
        pluginsConfiguration.html {
            customAssets.from(rootProject.file("site/static/images/logo.svg"))
            customStyleSheets.from(rootProject.file("site/logo-styles.css"))
            footerMessage.set("(c) Danilo Pianini and contributors listed in the Alchemist build files")
            homepageLink = "https://alchemistsimulator.github.io/"
        }
    }
}

tasks.withType<DokkaBaseTask>().configureEach {
    timeout.set(Duration.ofMinutes(5))
}

Installation

  • Operating system: Linux
  • Build tool: Gradle v8.11
  • Dokka version: 2.0.0
@DanySK DanySK added the bug label Dec 29, 2024
DanySK added a commit to AlchemistSimulator/Alchemist that referenced this issue Dec 29, 2024
DanySK added a commit to AlchemistSimulator/Alchemist that referenced this issue Dec 30, 2024
* feat: enable Dokka v2

* build: enable the kotest runner on multiplatform projects

* build: enforce consistency in the KMP subprojects

* ci: fix new task name

* ci: make sure to fail on broken links

* docs: link the home page

* ci: fix broken retry mechanism

* docs: fix links to KDoc

* docs: limit docs generation to subprojects until Kotlin/dokka#3979 is fixed

* docs: include both multi-module and overall documentation

* docs: only check the multimodule website

* docs: fix typo

* docs: revise replacements
DanySK pushed a commit to AlchemistSimulator/Alchemist that referenced this issue Dec 30, 2024
## [36.1.0](36.0.13...36.1.0) (2024-12-30)

### Features

* enable Dokka v2 ([#4056](#4056)) ([c8e3565](c8e3565)), closes [Kotlin/dokka#3979](Kotlin/dokka#3979)

### Dependency updates

* **deps:** update plugin java-qa to v1.81.0 ([#4054](#4054)) ([49bda56](49bda56))
* **deps:** update plugin java-qa to v1.82.0 ([#4055](#4055)) ([fe63220](fe63220))

### Build and continuous integration

* move the CI concurrency management to the dispatcher workflow ([#4058](#4058)) ([353e5dc](353e5dc))
* pin the version of ubuntu in the dispatcher workflow ([#4057](#4057)) ([b1daac5](b1daac5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant