在Java的Javadoc中,有一种方法可以使用{@inheritDoc}
tag继承子类中的方法文档。如何继承KDoc文档?
有没有办法在Kotlin的KDoc中做同样的事情?
基本上,我想要做的是:
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() { /* ... */ }
}
不'{@inheritDoc}'不行?你试过了吗? – CaseyB
@CaseyB,是的,我做过,IntelliJ和dokka都不理解它,它们只是将它显示为文本。 – hotkey
我找不到任何记录我的发现的东西,但从我所知道的情况来看,如果没有在覆盖中指定文档,Kotlin Doc会在覆盖函数时继承文档。现在我想知道的是如何“扩展”/“包含”基础文档... – mfulton26