I'm writing a custom Dokka format, including a cus...
# dokka
c
I'm writing a custom Dokka format, including a custom
DokkaLocationProvider
implementation. Currently, the documentation is generated using the human-readable module name:
dokkaContext.configuration.moduleName
which gives the output:
api/-my%20-example%20-module/package.name/Class.md
which isn't great for URLs. Instead, I'd prefer to use the module's Gradle project name, to get something like:
api/my-example-module/package.name/Class.md
Is this possible? I don't see anything that looks like that in
org.jetbrains.dokka.DokkaConfiguration
a
By default in DGPv2 (which I presume you're using?) the file path should be derived from the Gradle project path (see https://github.com/Kotlin/dokka/blob/v2.0.0/dokka-runners/dokka-gradle-plugin/src/main/kotlin/DokkaExtension.kt#L80-L102). So I guess the subproject with
class Class
has a path of
:api:my-example-module
. But it's strange that something is modifying it to add dashes and spaces, and then escaping the spaces! Does it happen in other output formats? I would dig around
:dokka-subprojects:dokka-base
, I guess something in there is modifying it.
c
I am using DGPv2, yes. It seems to me that the location is initialized from
moduleName
, not
modulePath
. Admittedly, I don't really understand how a
LocationProvider
should be written, so mine could be very wrong. LocationProvider: https://gitlab.com/opensavvy/automation/dokka-material-mkdocs/-/blob/main/renderer[…]main/kotlin/location/MarkdownLocationProvider.kt?ref_type=heads Config: https://gitlab.com/opensavvy/automation/dokka-material-mkdocs/-/blob/main/docs/example/example-core/build.gradle.kts?ref_type=heads#L15
If you want to see it for yourself, clone the project, at the root run
Copy code
./gradlew -p docs website:embedDokkaIntoMkDocs
then visit
docs/website/docs/api
, you'll see all the module name contains spaces
I think the "escape spaces to `%20`" is done by MkDocs, but I don't understand why there is a space in the filename in the first place