In Kotlin documentation (KDoc), is it possible to link to a specific overloaded method?

久未见 提交于 2020-02-03 12:14:13

问题


Consider the class comment of this Kotlin class:

/**
 * This class has two methods, one that takes one parameters ([foo]),
 * and another one that takes two parameters ([foo]).
 **/
class Clazz {
    /* Foo with one. */
    fun foo(a: Int) {  }

    /* Foo with two. */
    fun foo(a: Int, b: Int) {  }
}

I'd like the second link to point to the 2nd function ( the one with the two parameters ).

Is this possible in the Kotlin documentation language?


回答1:


Just found this answer:

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.

From https://kotlinlang.org/docs/reference/kotlin-doc.html

... but I don't really understand the reasoning.

Sounds like this makes sense in the context where docs are read separately from code, but most of the time when I read or use comments it's in the IDE UI.



来源:https://stackoverflow.com/questions/59400005/in-kotlin-documentation-kdoc-is-it-possible-to-link-to-a-specific-overloaded

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!