Hi there! I've added Dokka to my multiplatform + m...
# dokka
a
Hi there! I've added Dokka to my multiplatform + multimodule project and it works like a charm! The only problem I bumped into is that Dokka generates a file called
-modules.html
into the root directory of the resulting documentation instead of generating an
index.html
file. How can I tell Dokka to create an
index.html
instead? If I rename the file by hand it works, but I'd like to automate this.
👍 1
b
You can't. But you can automate renaming with custom gradle task
a
thanks!
m
We are working on improving the multimodule experience. This file will be renamed to
index.html
probably in next release
K 5
🎉 1
a
This sounds great! I'm releasing the docs only when a new version is deployed so this is not a serious issue.
Anyway, I'm really happy that Dokka works so well now, I used to struggle with it a lot (until I gave up)
@Marcin Aman a small suggestion: It is not crystal clear how
@sample
works. I had to look into Kotlin in Action and piece it together to figure this out. Maybe the docs can be improved a bit
another thing that I bumped into is that i have to pass a function name to
@sample
so my sample cannot contain imports. my current workaround is that i add the imports as comments
is there a better workaround for this?
example:
m
Thats weird, on my small project i run a basic example:
Copy code
package samples

import example.Clock

object Samples {
    fun js() {
        class SampleClock : Clock(10) {
            override fun equals(other: Any?): Boolean = true
        }
        println("Hi, JS!")
    }
}
And i get this import. Isn't it just hidden for you? (there is a plus icon on the top of the sample to expand it, they are present in the link you provided) Also if you want a sample-specific imports you either need to create a file per sample or use your comment method. As for the guide: it is in progress. Not only for the samples but for other dokka features as well.
a
What is your config for this?
I have this in my `build.gradle.kts`:
samples.from("src/commonMain/kotlin/org/hexworks/zircon/samples")
and this is my `@sample`:
Copy code
@sample org.hexworks.zircon.samples.ComponentSamples.fragment
Copy code
object ComponentSamples {

    fun fragment() {
        // import org.hexworks.cobalt.events.api.Subscription
        // import org.hexworks.zircon.api.Components
        // import org.hexworks.zircon.api.component.Fragment
        // import org.hexworks.zircon.api.uievent.ComponentEventType

        class ConfirmButton : Fragment {

            override val root = Components.button()
                    .withText("Confirm")
                    .build()

            fun onConfirm(fn: () -> Unit): Subscription {
                return root.processComponentEvents(ComponentEventType.ACTIVATED) {
                    fn()
                }
            }
        }
    }

}
the problem is that if I use
@sample org.hexworks.zircon.samples.ComponentSamples
all I can see in the samples block is
org.hexworks.zircon.samples.ComponentSamples
and no code
oh, i'm stupid
it was a typo on my part
now i see the contents of the class properly 👍 I don't see the imports though
m
Could you click the + above the sample code and see what is present there?
a
ah, it is there
great
👍
i'm so happy
i was struggling with Dokka so much
can I somehow change this part?
the docs + icon
m
you need to provide it in your build.gradle as a base plugin specific configuration with path to css and image. You can either do it by adding a base plugin to a buildscript -> dependencies -> classpath and using something like this:
Copy code
pluginConfiguration<DokkaBase, DokkaBaseConfiguration> {
    customAssets = listOf(file("<path to asset>"))
    customStyleSheets = listOf(file("<path to custom stylesheet>"))
}
Adding a base plugin is required to resolve those types. If you dont want to add this to your classpath you can just pase a json. Relevant links: https://kotlin.github.io/dokka/1.4.10.2/user_guide/gradle/usage/#applying-plugins https://github.com/Kotlin/dokka/blob/master/docs/src/doc/docs/user_guide/base-specific/frontend.md
a
i'd like to re-use the same css
or should i just copy this?
m
If all you need is replacing the logo and you need to add it in assets and create a css file named
logo-styles.css
with this one line:
Copy code
#logo {
    background-image: url('<https://upload.wikimedia.org/wikipedia/commons/9/9d/Ubuntu_logo.svg>');
    /* other styles required to make your page pretty */
}
Depending on your logo size/personal preference you can tweak it later
a
thanks
g
I’m sorry @Marcin Aman but I find the documentation and the instruction very unclear. What is “`pluginConfiguration` block”?
Is it in gradle API?
A complete sample project with custom logo, css would help a lot.
m
Something like this works for me: https://github.com/MarcinAman/dokka-example You can override more styles if you like by adding custom css files with the names specified here: https://kotlin.github.io/dokka/1.4.10.2/user_guide/base-specific/frontend/
🙏 2
👌 2