louiscad
04/04/2021, 6:55 PMJavier
04/04/2021, 11:40 PMJavier
04/04/2021, 11:41 PMimport org.jetbrains.dokka.gradle.DokkaMultiModuleTask
import org.jetbrains.dokka.gradle.DokkaTask
plugins {
id("org.jetbrains.dokka")
}
tasks {
withType<DokkaTask>() {
dokkaSourceSets.configureEach {
includes.from(listOf("MODULE.md"))
}
}
withType<DokkaMultiModuleTask>().configureEach {
val dokkaDir = buildDir.resolve("dokka")
outputDirectory.set(dokkaDir)
}
}
Javier
04/04/2021, 11:41 PMJavier
04/04/2021, 11:42 PM./gradlew dokkaHtmlMultiModule
Javier
04/04/2021, 11:43 PMlouiscad
04/05/2021, 8:25 AMDokkaMultiModuleTask
tasks required?
Also, how am I supposed to tell I only want KDoc for projects under a certain hierarchy, and not the other ones?Javier
04/05/2021, 8:34 AMJavier
04/05/2021, 8:36 AMlouiscad
04/05/2021, 8:36 AMJavier
04/05/2021, 8:37 AMJavier
04/05/2021, 8:38 AMlouiscad
04/05/2021, 8:39 AMJavier
04/05/2021, 8:39 AMJavier
04/05/2021, 8:40 AMlouiscad
04/05/2021, 8:42 AMModule.md
file? Also, do I need to put some content in it?Javier
04/05/2021, 8:42 AMJavier
04/05/2021, 8:43 AMJavier
04/05/2021, 8:44 AMJavier
04/05/2021, 8:45 AMJavier
04/05/2021, 8:45 AMJavier
04/05/2021, 8:45 AMJavier
04/05/2021, 8:46 AMJavier
04/05/2021, 8:48 AMZach Klippenstein (he/him) [MOD]
04/05/2021, 10:59 PMlouiscad
04/06/2021, 7:30 AMallProjects
block:
plugins.withId("org.gradle.maven-publish") {
plugins.apply("org.jetbrains.dokka")
tasks.withType<DokkaTask> {
dokkaSourceSets.configureEach {
includes.from("README.md")
}
}
}
Plus the following in the root Gradle build file:
plugins {
//... other plugins
kotlin("multiplatform") apply false // Classpath concerns for dokka, might be unneeded.
// See <https://github.com/Kotlin/dokka/issues/1810>
id("org.jetbrains.dokka")
}
louiscad
04/06/2021, 7:31 AM> Task :modules:experimental:dokkaGfmPartial FAILED
=============================== Gradle Doctor Prescriptions ============================================
| This build spent 40% garbage collecting. |
| If this is the first build with this Daemon, it likely means that this build needs more heap space. |
| Otherwise, if this is happening after several builds it could indicate a memory leak. |
| For a quick fix, restart this Gradle daemon. ./gradlew --stop |
========================================================================================================
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':modules:experimental:dokkaGfmPartial'.
> Java heap space
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at <https://help.gradle.org>
BUILD FAILED in 9m 39s
louiscad
04/06/2021, 7:45 AM=============================== Gradle Doctor Prescriptions ============================================
| This build spent 44% garbage collecting. |
| If this is the first build with this Daemon, it likely means that this build needs more heap space. |
| Otherwise, if this is happening after several builds it could indicate a memory leak. |
| For a quick fix, restart this Gradle daemon. ./gradlew --stop |
========================================================================================================
| The following operations were slower to pull from the cache than to rerun: |
| :modules:collections:jsIrGenerateExternalsIntegrated |
| Consider disabling caching them. |
| For more information see: <https://runningcode.github.io/gradle-doctor/slower-from-cache/> |
========================================================================================================
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':modules:preferences:dokkaGfmPartial'.
> GC overhead limit exceeded
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at <https://help.gradle.org>
BUILD FAILED in 8m 27s
Really bad first experience 😞
I'm gonna try bumping Gradle heap from 2GB to 3GB, but I find it insane that it's so memory inefficient.louiscad
04/06/2021, 7:58 AMdokkaGfmMultiModule
task 😡 🤬louiscad
04/06/2021, 8:30 AMwip-setup-dokka
branch.Javier
04/06/2021, 9:16 AMMarcin Aman
04/06/2021, 9:33 AMJavier
04/06/2021, 10:36 AMJavier
04/06/2021, 10:36 AMallproject { apply(plugin = "org.jetbrains.dokka") }
is not working for meJavier
04/06/2021, 10:37 AMid("org.jetbrains.dokka")
is generating the docsJavier
04/06/2021, 10:37 AMJavier
04/06/2021, 10:39 AMJavier
04/06/2021, 10:39 AMMarcin Aman
04/06/2021, 10:39 AMdokkaHtmlMultimodule
or dokkaGfmMultiModule
?Javier
04/06/2021, 10:40 AMJavier
04/06/2021, 10:40 AMJavier
04/06/2021, 10:41 AMJavier
04/06/2021, 10:42 AMMarcin Aman
04/06/2021, 10:48 AMif (file("README.md").exists()) tasks.withType<DokkaTaskPartial> {
dokkaSourceSets.configureEach {
includes.from("README.md")
}
}
This won’t work since readme-s are not formatted correctly. They should be in a format defined here: https://kotlinlang.org/docs/kotlin-doc.html#module-and-package-documentation. Also in multimodule you are configuring DokkaTaskPartial
not DokkaTask
As for the memory: i use 4G, it is quite a lot but the project is not a small one and it makes the build go faster (specially with some parallel workers).
Personally i’d add the split inheritors switch to configuration:
tasks.withType<DokkaTaskPartial> {
pluginsMapConfiguration.set(mapOf("org.jetbrains.dokka.base.DokkaBase" to """{ "separateInheritedMembers": true }"""))
}
Or by adding a base plugin to classpath:
https://kotlin.github.io/dokka/1.4.30/user_guide/gradle/usage/#applying-plugins
This will make an extra tab with members that are inherited so it is possible to see only those that are defined in certain class.
Personally i recommend using the html, since it works a little bit better for more complex projects (you get search + better navigation) and you can even use it when publishing to maven centrallouiscad
04/06/2021, 10:48 AMbuild.gradle.kts
files of every module for two reasons:
1. I'm lazy, and it's taking on my free-time
2. Generally speaking, all of the published modules should have KDoc, so I think Dokka should make that very common use-case super quick and easy to setup. Otherwise, it means the bigger the project, the most cumbersome it is to set it up. I know one can use Replace In Path, but that's still boilerplate, that make reviewing code more time consuming, with like, zero added value.Javier
04/06/2021, 10:50 AMMarcin Aman
04/06/2021, 10:50 AM./gradlew dokkaHtmlMultiModule --no-daemon --parallel --max-workers=3
louiscad
04/06/2021, 10:51 AMJavier
04/06/2021, 10:51 AMMarcin Aman
04/06/2021, 10:53 AMDokkaTask
to DokkaTaskPartial
in your configuration:
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':modules:activities:dokkaHtmlPartial'.
> Unexpected classifier: "#", expected either "Module" or "Package".
For more information consult the specification: <https://kotlinlang.org/docs/reference/kotlin-doc.html#module-and-package-documentation>
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================
louiscad
04/06/2021, 10:55 AMJavier
04/06/2021, 10:55 AMJavier
04/06/2021, 10:55 AMJavier
04/06/2021, 10:55 AMlouiscad
04/06/2021, 10:56 AMJavier
04/06/2021, 10:56 AMorg.gradle.parallel=false
, but I don't know if Dokka supports parallelism btwlouiscad
04/06/2021, 11:00 AMlouiscad
04/06/2021, 11:00 AMMarcin Aman
04/06/2021, 11:00 AMJavier
04/06/2021, 11:01 AMJavier
04/06/2021, 11:01 AMJavier
04/06/2021, 11:02 AMlouiscad
04/06/2021, 11:02 AMJavier
04/06/2021, 11:03 AMMarcin Aman
04/06/2021, 11:03 AMMarcin Aman
04/06/2021, 11:05 AMlouiscad
04/06/2021, 11:05 AMJavier
04/06/2021, 11:05 AMJavier
04/06/2021, 11:05 AMJavier
04/06/2021, 11:05 AMlouiscad
04/06/2021, 11:06 AMbuild.gradle.kts
files, right?Javier
04/06/2021, 11:06 AM./gradlew dokkaHtmlMultiModule -P"org.gradle.parallel"="true"
Javier
04/06/2021, 11:06 AMJavier
04/06/2021, 11:07 AMlouiscad
04/06/2021, 11:07 AMJavier
04/06/2021, 11:08 AMJavier
04/06/2021, 11:09 AMJavier
04/06/2021, 11:10 AMlouiscad
04/06/2021, 11:10 AMJavier
04/06/2021, 11:10 AMlouiscad
04/06/2021, 11:10 AMJavier
04/06/2021, 11:11 AMlouiscad
04/06/2021, 11:12 AMJavier
04/06/2021, 11:12 AMlouiscad
04/06/2021, 11:12 AMlouiscad
04/06/2021, 11:15 AMJavier
04/06/2021, 11:18 AMJavier
04/06/2021, 11:20 AMlouiscad
04/06/2021, 11:20 AMlouiscad
04/06/2021, 11:21 AMJavier
04/06/2021, 11:22 AMlouiscad
04/06/2021, 11:22 AMJavier
04/06/2021, 11:23 AMlouiscad
04/06/2021, 11:23 AMJavier
04/06/2021, 11:23 AMJavier
04/06/2021, 11:24 AMlouiscad
04/06/2021, 11:24 AMJavier
04/06/2021, 11:25 AMJavier
04/06/2021, 11:25 AMlouiscad
04/06/2021, 11:25 AMJavier
04/06/2021, 11:25 AMJavier
04/06/2021, 11:25 AMJavier
04/06/2021, 11:26 AMlouiscad
04/06/2021, 11:26 AMJavier
04/06/2021, 11:26 AMJavier
04/06/2021, 11:26 AMlouiscad
04/06/2021, 11:27 AMJavier
04/06/2021, 11:27 AMlouiscad
04/06/2021, 11:27 AMNop, you haven't itWhat are you talking about?
Javier
04/06/2021, 11:28 AMorg.gradle.configureondemand=true
louiscad
04/06/2021, 11:28 AMJavier
04/06/2021, 11:28 AMJavier
04/06/2021, 11:30 AMJavier
04/06/2021, 11:31 AMJavier
04/06/2021, 11:31 AMJavier
04/06/2021, 11:36 AMlouiscad
04/06/2021, 11:37 AMJavier
04/06/2021, 11:38 AMimport com.javiersc.plugins.core.isSignificant
import org.jetbrains.dokka.gradle.DokkaTask
plugins {
`maven-publish`
signing
id("org.jetbrains.dokka")
}
val docsJar by project.tasks.creating(Jar::class) {
group = "build"
description = "Assembles Javadoc jar file from for publishing"
archiveClassifier.set("javadoc")
dependsOn(tasks.named<DokkaTask>("dokkaHtml"))
}
configure<PublishingExtension> {
publications {
withType<MavenPublication> {
pom {
name.set(property("pomName").toString())
description.set(property("pomDescription").toString())
url.set(property("pomUrl").toString())
licenses {
license {
name.set(property("pomLicenseName").toString())
url.set(property("pomLicenseUrl").toString())
}
}
developers {
developer {
id.set(property("pomDeveloperId").toString())
name.set(property("pomDeveloperName").toString())
email.set(property("pomDeveloperEmail").toString())
}
}
scm {
url.set(property("pomSmcUrl").toString())
connection.set(property("pomSmcConnection").toString())
developerConnection.set(property("pomSmcDeveloperConnection").toString())
}
}
artifact(docsJar)
}
}
}
louiscad
04/06/2021, 11:38 AMbuildSrc
Javier
04/06/2021, 11:38 AMJavier
04/06/2021, 11:39 AMJavier
04/06/2021, 11:39 AMJavier
04/06/2021, 11:39 AMJavier
04/06/2021, 11:40 AMplugins {
maven-publish
id("org.jetbrains.dokka")
}
Javier
04/06/2021, 11:42 AMafterEvaluate
in some projects and in bitflags
no?louiscad
04/06/2021, 11:47 AMlouiscad
04/06/2021, 11:48 AMafterEvaluate
is required modules that have and Android target.Javier
04/06/2021, 11:51 AMlouiscad
04/06/2021, 11:52 AMJavier
04/06/2021, 11:52 AMJavier
04/06/2021, 11:52 AMJavier
04/06/2021, 11:52 AMJavier
04/06/2021, 11:53 AMJavier
04/06/2021, 11:53 AMlouiscad
04/06/2021, 11:53 AMsplitties-
, not just the directoriesJavier
04/06/2021, 11:53 AMJavier
04/06/2021, 11:53 AMlouiscad
04/06/2021, 11:54 AMlouiscad
04/06/2021, 11:54 AMviews-dsl-material
, it depends on several other ones.louiscad
04/06/2021, 11:56 AMJavier
04/06/2021, 11:56 AMlouiscad
04/06/2021, 11:56 AM.module
file referencing the correct ones?louiscad
04/06/2021, 11:57 AMlouiscad
04/06/2021, 11:58 AMJavier
04/06/2021, 11:58 AMJavier
04/06/2021, 11:59 AMJavier
04/06/2021, 11:59 AMJavier
04/06/2021, 12:03 PMJavier
04/06/2021, 12:03 PMKamil Doległo
04/06/2021, 2:01 PMwip-setup-dokka
branch is almost OK @louiscad, you just have to make some small adjustments:
◦ change the configureEach<DokkaTask>
to configureEach<DokkaTaskPartial>
(and the relevant import as well)
◦ probably increase the JVM memory limit with something like org.gradle.jvmargs=-Xmx6g
, because the compilation is failing (this project has a significant size after all)
◦ format your README.md
s correctly for Dokka (see https://kotlinlang.org/docs/kotlin-doc.html#module-and-package-documentation)
2. There is no need to edit all buildfiles, everything works from the root one with allprojects
block. There is no need to create a precompiled plugin too, you can however do that if you want to.
3. If you want to speedup the documentation you can reenable parallelism or just run Gradle with ./gradlew --parallel :dokkaHtmlMultiModule
or whichever Dokka task you want.
4. I’m sorry to hear that you find the documentation ambiguous. Could you please tell me what is ambiguous for you and how would you like it to look?louiscad
04/06/2021, 2:12 PMallProjects
, and 3GB is enough (though I might experiment with more like 6GB once I understand what setting gigantic heap spaces implies, including machines with only 8GB or RAM and way less free if not swap) but yes, you got everything right.
About doc: There's a stuffed README, a website and a GitHub Wiki. It's not clear if one is abandoned and one is more a source of truth than the other. Ideally, the README would have a big link towards the website, and the FAQ and Wiki content would move to the website, or it would be mentioned from the website at a discoverable place.
Once that is cleared up, I'd like for the doc to simply show how to set it up for a Gradle project (no matter Android, Multiplatform or just JVM), mentioning settings to check to avoid bad onboarding experience (like HEAP size, Module.md files format), and have a less overwhelming presentation of the configuration options where you don't need to constantly scroll sideways to read every sentence, plus more clarity about the default values, so we know if it's something the default would not best fit for us.