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

Can't reference a specific function overload #80

Open
ghost opened this issue May 26, 2016 · 25 comments
Open

Can't reference a specific function overload #80

ghost opened this issue May 26, 2016 · 25 comments
Labels
kdoc-spec An issue that requires clarification from the KDoc spec's perspective

Comments

@ghost
Copy link

ghost commented May 26, 2016

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.

@alexfacciorusso
Copy link

Same problem here.

@fabienmoritz
Copy link

It is never too late to answer a good suggestion ! 😅

@Sxtanna
Copy link

Sxtanna commented Nov 24, 2017

This should 100% be supported, this is essential...

@NoHarmDan
Copy link

How is this still not supported?! The suggested solution would look perfectly fine.

@alllex
Copy link

alllex commented Nov 29, 2018

Moreover, this missing feature may make documentation browsing a bit misleading. It may be possible to dodge overloading with default parameters in Kotlin, but impossible when operating with JDK classes.

Consider the case when you mention Java method which has several overloads in your Kotlin doc of foo. When you open a quick documentation for foo the Java method mention is shown as a link clicking on which may bring you to the documentation of an incorrect overload.

@chrisjenx
Copy link

This still isn't supported?

@projectdelta6
Copy link

I agree this is needed

@MikhailShumenko
Copy link

Is it fixed?

@fo2rist
Copy link

fo2rist commented Jun 1, 2019

Looks like it's not. See the doc

Note that KDoc does not have any syntax for resolving overloaded members in links. Since the Kotlin documentation generation tool puts the documentation for all overloads of a function on the same page, identifying a specific overloaded function is not required for the link to work.

Any news from JetBrains team?

@zach-klippenstein
Copy link

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.

@christopherfrieler
Copy link

I just came across this limitation and would definitely appreciate to see this fixed for the same reason: it is really annoying to have these "broken" links in my IDE.

At the same time I'm not sure if this is something to be done in dokka in the first place. The Kotlin Spec doesn't say anything about how links into Kotlin code are specified or resolved (see Documentation comments). Instead there's a big TODO.

I think the Spec should specify this first. Then (or maybe simultaneously) tools like dokka or any IDE can implement that. I assume IntelliJ/Android Studio doesn't use dokka internally anyway to resolve those links, so just implementing that in dokka wouldn't even help in my IDE.

@DavidSonoda
Copy link

It is never too late to answer a good suggestion ! 😅

Strongly agreed! It's confusing to see those broken links.

@cgruber
Copy link

cgruber commented Mar 27, 2020

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.

@vincentfree
Copy link

Same problem, this looks like something that just should be there. I'm trying to document some usage of the jdk Cipher's doFinal method, im trying to express the usage of .doFinal(ByteArray) but it defaults too .doFinal() this isn't what's happening so the documentation isn't documenting the intent this way

@vad-zuev
Copy link

vad-zuev commented Jul 7, 2020

still no updates on this? I can just repeat what others said: being unable to link a specific overload is really frustrating ><

@kamildoleglo
Copy link
Contributor

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

@Kordyjan Kordyjan added this to the Post-Stable milestone Sep 1, 2020
corycaywood added a commit to corycaywood/android-miniapp that referenced this issue Sep 28, 2020
The new format here I've used here is also incorrect because KDocs don't currently support documentation for overloaded methods: Kotlin/dokka#80. So maybe this is the best compromise until they do add support
corycaywood added a commit to rakutentech/android-miniapp that referenced this issue Sep 29, 2020
The new format here I've used here is also incorrect because KDocs don't currently support documentation for overloaded methods: Kotlin/dokka#80. So maybe this is the best compromise until they do add support
@akamuza
Copy link

akamuza commented Aug 30, 2021

Still an issue in 2021

@ichenhe
Copy link

ichenhe commented Sep 7, 2021

I have to give the function a different name. It's troublesome.

@vmishenev vmishenev added the kdoc-spec An issue that requires clarification from the KDoc spec's perspective label Dec 5, 2021
@Ahmed-Mostafa-Ghanayem
Copy link

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

@IgnatBeresnev
Copy link
Member

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.

@vmishenev
Copy link
Member

This is actual for a function and a property with the same name:

val name = ""
fun name() = ""

@IgnatBeresnev IgnatBeresnev removed this from the Backlog milestone Aug 22, 2023
@HalfLegend
Copy link

Still an issue in 2023

@rexmtorres
Copy link

Still an issue in 2023

And still in 2024

@wallind
Copy link

wallind commented Apr 4, 2024

Adding my voice as someone who just went to do this, and found I could not....bummer.

Also, to add a laugh, JetBrains AI Assistant lied to me and told me I could 🙃 ...lol - ai-telling-lies-about-kdoc.txt

@aaprokofyev
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kdoc-spec An issue that requires clarification from the KDoc spec's perspective
Projects
None yet
Development

No branches or pull requests