dokka: Can't reference a specific function overload

Consider this scenario: I have two or more methods with the same name but different parameters, just simple function overloads. Then I can’t reference one of them explicitly in the documentation.

For example:

class Sample {
    /**
     * If calling this, don't call [fancy] or [fancy] before [build].
     */
    fun fancy(value: String) { ... }
    fun fancy(value: Int) { ... }
    fun fancy(value: String, extra: String) { ... }
    fun build(): Something { ... }
}

Something like [fancy(Int)] and [fancy(String, String)] would be nice in the scenario, to separate the reference by parameter types and thus being able to reference one specific overload.

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Reactions: 117
  • Comments: 24 (3 by maintainers)

Commits related to this issue

Most upvoted comments

It may not be required for HTML outputs, but when linking to code in the IDE it is extremely frustrating to not be able to link to a specific overload. E.g. Clicking a link to Job.cancel will take you to the deprecated cancel() function. Clicking a link to kotlinx.coroutines.cancel will take you to CoroutineContext.cancel, and there’s no way to link to CoroutineScope.cancel.

This issue will celebrate 6th birthday soon and still no updates.

Hi, yeah 😃 Unfortunately, this problem spans beyond dokka (kdoc spec, probably some compiler/ide work as well), so it’s not as easy to fix, but it’s definitely on our radar, we’ll keep you posted if anything update-worthy comes up.

Still an issue in 2023

Still an issue in 2021

I’ve now renamed methods to avoid this issue, and not actually useful renames. Please consider supporting function overload targeting, especially since not all overloads are the result of defaults, but may take very different types (but do the same thing, and thus be usefully named the same.

Still an issue in 2023

And still in 2024

Same problem here.

This should 100% be supported, this is essential…

Sorry, still nothing from our side as this is a change in KDoc that must be done by the IntelliJ team, here’s the relevant ticket: https://youtrack.jetbrains.com/issue/KT-15984