https://kotlinlang.org logo
#dokka
Title
z

zsmb

02/10/2021, 12:54 PM
I’m trying to generate Dokka documentation for an Android project with custom Views, and the supertype’s declarations being dumped into the docs make them completely unusable at the moment 😞
View
and
ViewGroup
have their own documentation on the Android Developer website, there’s no need to show their hundreds of methods in our docs. Our custom methods are essentially impossible to find this way. I found an already open issue for this with no responses https://github.com/Kotlin/dokka/issues/1501 Any chance that this will be addressed soon, or is there any workaround to this problem?
2
🤩 1
l

Lukas K-G

02/10/2021, 1:07 PM
If you use the development version, there is an option to have inherited functions in a separate tab:
separateInheritedMembers
that might help for now. See here for documentation. Not sure in which release that will be.
z

zsmb

02/10/2021, 1:09 PM
That would actually be really helpful - what do I need to do to get on the dev version?
Or is that unpublished, and I’d have to build it myself?
l

Lukas K-G

02/10/2021, 1:11 PM
you need to add
Copy code
repositories {
    maven {
        url  "<https://dl.bintray.com/kotlin/kotlin-dev>" 
    }
}
to your maven repositories.
Then you can simply do e.g.
Copy code
implementation 'org.jetbrains.dokka:all-modules-page-plugin:1.4.20.2-dev-60'
Actually I just tried that and did not get it to work but I had that working once. Let me have another quick look.
🙏 1
z

zsmb

02/10/2021, 1:30 PM
I was gonna ask how to set this up, pulled in this version, added this config
Copy code
dokkaHtml.configure {
    dokkaSourceSets {
        configureEach {
            separateInheritedMembers = true
        }
    }
}
But I still get all the superclass stuff in the same view.
l

Lukas K-G

02/10/2021, 1:32 PM
this needs to go in the
pluginsMapConfiguration
. Do you have
.gradle
or
.gradle.kts
?
z

zsmb

02/10/2021, 1:32 PM
Regular
.gradle
files
l

Lukas K-G

02/10/2021, 1:33 PM
Bad luck. Now it is getting ugly. 😬 You need to add the following:
😄 1
Copy code
pluginsMapConfiguration.set(
            ["org.jetbrains.dokka.base.DokkaBase": """{ "separateInheritedMembers": true}"""]
    )
I hope I got all the brackets right. 🙈
z

zsmb

02/10/2021, 1:36 PM
Hmm, where do I add this? It’s an Android project, so there’s a top level Gradle build file, and then per-module ones as well.
z

zsmb

02/10/2021, 1:38 PM
Ah, got it, within the Dokka task config - I’ll give it a spin, fingers crossed 😄
🤞 1
l

Lukas K-G

02/10/2021, 1:39 PM
I had to change the maven repo and the dependency on my side:
Copy code
maven {
            url '<https://maven.pkg.jetbrains.space/kotlin/p/dokka/dev>'
        }
and
Copy code
classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.4.20.2-dev-62")
Should produce something like this:
z

zsmb

02/10/2021, 1:55 PM
I got this new version, and have this as my config in each of my modules:
Copy code
dokkaHtml.configure {
    pluginsMapConfiguration.set(
            ["org.jetbrains.dokka.base.DokkaBase": """{ "separateInheritedMembers": true}"""]
    )
}
But I don’t get the separate tab yet 😞
I’ll try putting this config on the
dokkaHtmlPartial
task instead
l

Lukas K-G

02/10/2021, 2:00 PM
For me it looks like this:
Copy code
tasks.withType(dokkaHtml.getClass()).configureEach { 
 dokkaSourceSets {
....
}
 pluginsMapConfiguration.set(
            [
                    "org.jetbrains.dokka.base.DokkaBase": """{ "separateInheritedMembers" : true, "customStyleSheets": ["${file("../documentation/logo-styles.css")}","${file("../documentation/styles.css")}"], "customAssets" : ["${file("../documentation/docs_logo.svg")}", "${file("../documentation/logo-icon.svg")}"]}"""
            ]
    )
}
But that should not make any difference I think. Are you sure you have the dev version? The logo in the top left should be a link now if so.
z

zsmb

02/10/2021, 2:10 PM
Ah, awesome, got it to work
I’ve added so much config that I’m not sure which one it needed, I’ll have to binary search for it now 😄
l

Lukas K-G

02/10/2021, 2:12 PM
😂 good luck. Disclaimer: There is nothing officially documented as far as I know. I just found it by looking trough code. So use at your own risk. 🚀
z

zsmb

02/10/2021, 2:42 PM
Understood, thank you for all the help! 🙇 I found two stable configs. I’m running
gradlew dokkaHtmlMultimodule
which runs
dokkaHtmlPartial
in each module, so I need either of these config blocks for this to work:
Copy code
dokkaHtmlPartial.configure {
    pluginsMapConfiguration.set(
            ["org.jetbrains.dokka.base.DokkaBase": """{ "separateInheritedMembers": true}"""]
    )
}

tasks.withType(dokkaHtmlPartial.getClass()).configureEach {
    pluginsMapConfiguration.set(
            ["org.jetbrains.dokka.base.DokkaBase": """{ "separateInheritedMembers": true}"""]
    )
}
👍 2
l

Lukas K-G

02/10/2021, 2:44 PM
Quick not:
dokkaHtmlPartial.getClass()
is just a way to get the
DokkaTask
class. I did not find any other solution. So this runs for all tasks of type
DokkaTask
.
z

zsmb

02/10/2021, 3:02 PM
Apparenty it matters whether it’s
dokkaHtml.getClass()
or
dokkaHtmlPartial.getClass()
, the former doesn’t work
Printing them shows that they return slightly different values
Copy code
class org.jetbrains.dokka.gradle.DokkaTask_Decorated
class org.jetbrains.dokka.gradle.DokkaTaskPartial_Decorated
l

Lukas K-G

02/10/2021, 3:03 PM
Oh, good to know!
47 Views