Kotlin / dokka

API documentation engine for Kotlin
https://kotl.in/dokka
Apache License 2.0
3.44k stars 409 forks source link

Remove source set display name from Gfm output, can it be done? #1921

Open pkeno opened 3 years ago

pkeno commented 3 years ago

Question When I generate documentation using the dokkaGfmCollector in a multi module project, i am able to set the display name of a module source set using the displayName.set("some-name") configuration option. In the generated .md-files this results in [some-name] in various places.

I would like to have this displayName (including the brackets) removed from the output. Is this possible somehow?

Installation

Additional context My current, per module configuration:

dokkaGfm {
    outputDirectory.set(new File("$buildDir/gfm"))
    dokkaSourceSets {
        named("main") {
            displayName.set("${project.name}")
            skipEmptyPackages.set(false)
            skipDeprecated.set(true)
            noStdlibLink.set(true)
            // Use to include or exclude non public members
            includeNonPublic.set(false)
        }
    }
}
MarcinAman commented 3 years ago

Could you give me an example of those places?

pkeno commented 3 years ago

Sure thing! This class:

package com.example

class ExampleClass {
    fun foo() : ExampleClass {
        return ExampleClass()
    }
}

gives this index.md-file contents:

//[project](../../../index.md)/[com.example](../index.md)/[ExampleClass](index.md)

# ExampleClass  
 [commons] class [ExampleClass](index.md)   

## Functions  

|  Name |  Summary | 
|---|---|
| <a name="com.example/ExampleClass/foo/#/PointingToDeclaration/"></a>[foo](foo.md)| <a name="com.example/ExampleClass/foo/#/PointingToDeclaration/"></a>[commons]  <br>Content  <br>fun [foo](foo.md)(): [ExampleClass](index.md)  <br><br><br>|

I am referring to the [commons] found in e.g [commons] class [ExampleClass](index.md) and in the functions summary.

I know that I can change it to something else, using the displayName.set("some name") configuration. But can I remove it completely. Setting it to displayName.set("") gives [] which is not what I want.

MarcinAman commented 3 years ago

No, unfortunately they can't be removed. Multiplatform in GFM is generally a hard topic that requires some improvements.

A quick and dirty work-around would be to remove them using some form of regex. You can also write a plugin if you wish to have a more reliable solution, here is a template: https://github.com/Kotlin/dokka-plugin-template