在 kDoc 中使用 @link 和别名
Using @link with aliases in kDoc
在 Java 文档中,我可以执行以下操作:
/**
* {@link FancyComp mFancy} is a variable that you need
*/
当然,我如何在 Kotlin 文档中执行此操作以获得相同的结果?
@link
在 kDoc 中不存在,但可以很容易地替换为 Inline Markup。
来自 KotlinDoc Linking to Elements
Inline Markup
For inline markup, KDoc uses the regular Markdown syntax, extended to
support a shorthand syntax for linking to other elements in the code.
Linking to Elements
To link to another element (class, method, property or parameter),
simply put its name in square brackets:
Use the method [foo]
for this purpose.
If you want to specify a custom
label for the link, use the Markdown reference-style syntax:
Use [this method][foo]
for this purpose. You can also use qualified
names in the links. Note that, unlike JavaDoc, qualified names always
use the dot character to separate the components, even before a method
name:
Use [kotlin.reflect.KClass.properties]
to enumerate the properties of
the class. Names in links are resolved using the same rules as if the
name was used inside the element being documented. In particular, this
means that if you have imported a name into the current file, you
don't need to fully qualify it when you use it in a KDoc comment.
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.
在 Java 文档中,我可以执行以下操作:
/**
* {@link FancyComp mFancy} is a variable that you need
*/
当然,我如何在 Kotlin 文档中执行此操作以获得相同的结果?
@link
在 kDoc 中不存在,但可以很容易地替换为 Inline Markup。
来自 KotlinDoc Linking to Elements
Inline Markup
For inline markup, KDoc uses the regular Markdown syntax, extended to support a shorthand syntax for linking to other elements in the code.
Linking to Elements
To link to another element (class, method, property or parameter), simply put its name in square brackets:
Use the method
[foo]
for this purpose.If you want to specify a custom label for the link, use the Markdown reference-style syntax:
Use
[this method][foo]
for this purpose. You can also use qualified names in the links. Note that, unlike JavaDoc, qualified names always use the dot character to separate the components, even before a method name:Use
[kotlin.reflect.KClass.properties]
to enumerate the properties of the class. Names in links are resolved using the same rules as if the name was used inside the element being documented. In particular, this means that if you have imported a name into the current file, you don't need to fully qualify it when you use it in a KDoc comment.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.