Hey, how exactly can you include images? using ```...
# dokka
h
Hey, how exactly can you include images? using
Copy code
dokkaSourceSets.configureEach {
    includes.from("README.md", "docImages/")
}
requires to create a folder
docImages
in every module...
m
why do you need to include images this way?
h
What is the alternative? 😄 I want to include images in my
ReadMe.md
, which is presented in the module description
m
Are those images available somewhere? Like github/other hosting? Maybe all that is needed is to add a link to the page
h
Nope, only locally.
m
Do it via plugins configuration. Something like this works for html:
Copy code
pluginConfiguration<org.jetbrains.dokka.base.DokkaBase, org.jetbrains.dokka.base.DokkaBaseConfiguration> {
    customAssets = listOf(file("test.png"))
}
and you reference this image as:
Copy code
![test](images/test.png)
You can find out more about pluginsConfiguration here: https://kotlin.github.io/dokka/1.5.0/user_guide/gradle/usage/#applying-plugins
h
do you have to include all images every time? Or could you provide a folder?
m
i think folder will also work
h
this requires using the Gradle
buildSrc
and it is not available using plain old
build.gradle.kts
files, right? 😄
m
it works well in kts using:
Copy code
buildscript {
    dependencies {
        classpath("org.jetbrains.dokka:dokka-base:1.5.0")
    }
}
If you dont want to include this dependency in buildscript you can always fallback to the json method
h
Hm, I don't get it working...
m
You are using a multimodule documentation and in this case all assets are on the root level. So your configuration should look like this:
Copy code
tasks.dokkaHtmlMultiModule {
    includes.from("README.md")
    pluginConfiguration<org.jetbrains.dokka.base.DokkaBase, org.jetbrains.dokka.base.DokkaBaseConfiguration> {
        customAssets = listOf(file("a/docImages/"))
    }
}
Later this is a case of adding a correct link to image. In case of this example:
![](../images/doc-images/Bildschirmfoto.png)
h
Thanks, now I all my images are collected in
root/build/dokka/htmlMultiModule/images/doc-images/
Copy code
// not nice, but working without manually re-enter all projects again
tasks.dokkaHtmlMultiModule { // root tasks in build.gradle.kts
    includes.from("README.md")
    pluginConfiguration<org.jetbrains.dokka.base.DokkaBase, org.jetbrains.dokka.base.DokkaBaseConfiguration> {
        customAssets = subprojects.map { "${it.path.drop(1).replace(":", "/")}/docImages/" }.mapNotNull {
            File("${project.projectDir.path}/$it").takeIf { it.exists() }
        }
    }
}
But it looks like, I have to change the paths in the Readme files too, right? This would mean, it is not possible to see the images in the readme viewer in Intellij/GitHub. In theory, it would be perfect, if Dokka will prefix all images paths with "/images".
297 Views