如何继承KDoc文档? [英] How do I inherit KDoc documentation?
问题描述
In Java's Javadoc, there is a way to inherit a method's documentation in a subclass using {@inheritDoc}
tag.
在Kotlin的KDoc中有没有办法做同样的事情?
Is there a way to do the same in Kotlin's KDoc?
基本上,我想做的是以下事情:
Basically, what I'd like to do is the following:
abstract class Base {
/**
* Some KDoc documentation here.
*/
abstract fun foo()
}
class Derived: Base() {
/**
* Here is all the documentation from Base#foo's KDoc inherited.
*
* And here goes something more in addition.
*/
override fun foo() { /* ... */ }
}
推荐答案
如果继承的成员没有自己的文档,Dokka总是将文档从基本成员复制到继承的成员.无法将基本成员文档与继承成员中提供的其他文本结合在一起.
Dokka always copies the documentation from a base member to an inherited one if the inherited member does not have its own documentation. There is no way to combine the base member documentation with additional text provided in the inherited member.
(Dokka不支持Java文档的@inheritdoc
标签,因为这不可避免地导致仅由/** @inheritdoc */
组成的注释的泛滥,我认为这些注释毫无用处和多余.)
(Dokka doesn't support the @inheritdoc
Javadoc tag because this inevitably leads to the proliferation of comments consisting of only /** @inheritdoc */
which I find super useless and redundant.)
这篇关于如何继承KDoc文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!