Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gfm adding consecutive ~~ for deprecated code #2177

Closed
stevenzeck opened this issue Oct 5, 2021 · 4 comments
Closed

Gfm adding consecutive ~~ for deprecated code #2177

stevenzeck opened this issue Oct 5, 2021 · 4 comments
Labels
bug format: gfm An issue/PR related to Dokka's GFM output format

Comments

@stevenzeck
Copy link

stevenzeck commented Oct 5, 2021

Describe the bug
When running Gfm against code marked with @Deprecated, it adds consecutive ~~ in certain cases. Take this example:

data class Test(
    val var1: Int? = null,
    val var2: String? = null
) {
    /**
     *
     * @param var3 A parameter
     */
    @Deprecated("This is deprecated")
    fun test(var3: Int) {
    }
}

This produces a test.md file (among other md files) with the following contents:

# test

[androidJvm]\
~~fun~~ [~~test~~](test.md)~~(~~~~var3~~~~:~~ [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)~~)~~

## Parameters

androidJvm

| | |
|---|---|
| var3 | A parameter |

Expected behaviour
I think ideally there would only be ~~ at the beginning and end of this entire line: fun test(var3: Int). It looks like however it is being parsed, it is passing in each of these when being sent to buildText, so each is surrounded with ~~:

  • fun
  • test
  • (
  • var3
  • :
  • )

Screenshots
N/A

To Reproduce
You can use that data class example above and generate Gfm docs from it.

Dokka configuration
Configuration of dokka used to reproduce the bug

        tasks.named("dokkaGfmPartial") {
            dokkaSourceSets {
                configureEach {
                    reportUndocumented.set(false)
                    skipEmptyPackages.set(false)
                    skipDeprecated.set(false)
                }
            }
        }

Installation

  • Operating system: macOS
  • Build tool: Gradle v6.8.0
  • Dokka version: 1.5.32

Additional context
N/A

Are you willing to provide a PR?
I can try if someone points me in the right direction. I've tried setting this up locally to debug against an Android project, but couldn't do anything other than get it to log.

@stevenzeck stevenzeck added the bug label Oct 5, 2021
@stevenzeck stevenzeck changed the title Gfm adding too many ~~ for deprecated code Gfm adding consecutive ~~ for deprecated code Oct 5, 2021
@vmishenev vmishenev added the format: gfm An issue/PR related to Dokka's GFM output format label Oct 5, 2021
@stevenzeck
Copy link
Author

I wouldn't mind trying to help fix this. I've gone through the code a bit; is there a test that can be created that takes raw Kotlin and can output the HTML and/or markdown as a String? https://github.com/Kotlin/dokka/blob/master/plugins/gfm/src/test/kotlin/renderers/gfm/SimpleElementsTest.kt#L73 only covers how it renders, not how it parses.

@vmishenev
Copy link
Member

Yes, e.g. there is https://github.com/Kotlin/dokka/blob/master/plugins/base/src/test/kotlin/signatures/SignatureTest.kt
I think for GFM format you can add GFM plugin to pluginOverrides.

@stevenzeck
Copy link
Author

Thanks. I created and pushed a test, keeping an incorrect expected: https://github.com/stevenzeck/dokka/blob/gfm-deprecated-fix/plugins/gfm/src/test/kotlin/renderers/gfm/ParseRenderTest.kt.

I'm still thinking of the best way to fix this, preferably keeping it limited to the CommonmarkRenderer. It is complicated by the fact that GitHub doesn't strikethrough special characters in the middle of text. e.g.

Int~~(~~ doesn't work, while Int ~~(~~ does: Int (
since it has a space in there.

@vmishenev
Copy link
Member

#2622 Now we have strikethrough only for declaration names and not for the whole signature as before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug format: gfm An issue/PR related to Dokka's GFM output format
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants