在Java中,如果要记录包,则必须将其放入package-info.class文件中.对于Kotlin和KDoc来说,这仍然是一回事吗?我查看了一些Kotlin源代码,无法找到编写包文档的位置.
如果我有一个项目有java,groovy和kotlin插件应用每个代码编写的代码,我如何创建(我应该)创建一个javadoc.jar包含所有代码文档的分发?
该java插件给我的javadoc课,groovy插件给我的groovydoc任务,但这些似乎并没有合作.
如何将此文档"合并"为单个内聚工件?
object我的项目中有类似以下内容
object UrlUtils {
private const val PARAM = "whatever"
/**
* Method that appends the [PARAM] parameter to the url
*/
fun appendParameter(url: String) {
// ...
}
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我想PARAM在方法的 KDoc 注释中引用字段的值appendParameter,但是在查看注释时,我看不到实际值,而只看到字段的名称。
将 PARAM 参数附加到 url 的方法
我想要的是:
将whatever参数附加到url的方法
在 Javadoc 中,这是通过使用来实现的{@value PARAM},但在 KDoc 中似乎没有类似的东西。甚至自动代码转换器也保留旧的 Javadoc。
所以我的问题是:我是否遗漏了什么,或者 KDoc/Dokka 是否缺少此功能?
我有一个带有辅助构造函数的 Kotlin 类,应该在特定场景中使用。现在这应该从第一个构造函数中正确记录下来,以便您可以立即看到它。
/**
* This is my class.
*
* @constructor This is the primary constructor meant for Scenario A.
* If you are in Scenario B, please use [reference to secondary constructor] <- what do I put in here?
*/
class MyClass(val a: String) {
constructor(b: Int) : this("$b abc")
}
Run Code Online (Sandbox Code Playgroud)
我不知道在用于引用成员/函数的方括号中放什么,但我觉得这应该是可能的。如果有人对此了解更多,那就太好了
我正在撰写文档评论来描述一种方法.
/**
* <p>necessary
* <p>setType is to set the PendingIntend's request code</p>
*/
Run Code Online (Sandbox Code Playgroud)
但它不会显示段落.如果我不使用<p>,所有文档都在一行中没有任何中断.它适用于Java类,但是当谈到Kotlin时,我不知道如何处理它.
我目前正在测试 Dokka 文档,我所做的一些注释没有被渲染。以下是我的发现:
@sample, 和 html 标签<p></p>, <h1></h1>: 请参阅 SimpleCalculator类文档enum class OPERATOR代码文档@sample:@property请参阅所有方法代码文档@property和之间的定义混合@param。在类声明中, the@param是 a 内的那个<>(例如Group<T>)。但在方法中,它是参数内的那个。请看我的代码:
package example
/**
* <h1> A Simple Calculator for your daily needs! </h1>
*
* <p> This class can help you add, subract, multiply and divide Integers </p>
*
* @property firstNumber the first Number you want to …Run Code Online (Sandbox Code Playgroud) 我们的Java DTO中通常包含一个由Javadoc中定义的表组成的更改日志:
/**
* Changelog:
*
* <table>
* <tr><th>Version</th><th>Description</th></tr>
* <tr>
* <td>2</td>
* <td>Added field 'something'</td>
* </tr>
* <tr>
* <td>3</td>
* <td>Added field 'somethingElse'</td>
* </tr>
* </table>
*/
public class MyDTO {
...
}
Run Code Online (Sandbox Code Playgroud)
这使得(在Intellij中使用Javadoc预览版)很好地呈现如下:
现在我们想为我们的Kotlin数据类做同样的事情.阅读KDoc的文档,其中说:
对于内联标记,KDoc使用常规Markdown语法,扩展为支持用于链接到代码中其他元素的简写语法.
所以我尝试使用Markdown语法创建一个表:
/**
* Changelog:
*
*| Version | Description |
*| ------------- | -------------------------- |
*| 2 | Added field 'something' |
*| 3 | Added field 'somethingElse' |
*
*/
data class MyKotlinDTO(..) {
... …Run Code Online (Sandbox Code Playgroud) 有谁知道记录 Ktor 路线的正确方法是什么,旨在将其显示在 KDoc 上?例子:
route(DogoBot.data.API.ROUTE){
route("token"){
route("add"){
get("fromdiscord") { ... }
get { ... }
}
}
route("user"){
route("{id}") {
get { ... }
}
}
route("guild"){
route("{id}") {
get { ... }
}
}
}
Run Code Online (Sandbox Code Playgroud)
好吧,如果可能的话,我该怎么做?我应该在其中放入哪种类型的信息?如何在其他方面实现 Ktor 兼容性?(我还有一个自己制作的路由器用于其他用途)
我想知道是否有可能将类的静态字段的值包含到类方法的文档中。
我们可以通过方括号链接类成员和参数:
/**
* Sets the title of the notification dialog using [title]
*
* The maximum title length allowed is [MAX_TITLE_LENGTH]
*/
fun setTitle(title: String): NotificationDialog.Builder {
if(title.length <= MAX_TITLE_LENGTH)
mTitle = title
else
mTitle = title.substring(0, MAX_TITLE_LENGTH)
return this
}
Run Code Online (Sandbox Code Playgroud)
目标
但我想拥有的价值MAX_TITLE_LENGTH在方法文档中获得 的值,而不是其名称的链接。
为了完整起见,这是我的类定义:
class Builder(val context: Context) {
private var mTitle = ""
/**
* Sets the title of the notification dialog using [title]
*
* The maximum title length allowed is [MAX_TITLE_LENGTH]
*/
fun …Run Code Online (Sandbox Code Playgroud) 我正在尝试为我的 kotlin 代码生成文档。我的一些类和函数有 KDOC 注释。
我试图像这样从 CLI 运行 dokka:
java -jar dokka-cli-1.4.20.jar
结果是:
警告:Dokka 1.4.* 是一个 alpha 项目进度:初始化插件加载插件:[] 加载:[
] 抑制:[
] PROGRESS:有效性检查 PROGRESS:创建文档模型 PROGRESS:退出生成:没有任何记录 PROGRESS:
=== 时间测量 ===
Run Code Online (Sandbox Code Playgroud)Initializing plugins: 26 Validity check: 32 Creating documentation models: 28 Exiting Generation: Nothing to document: 1
我试图执行这个:
所有运行的结果都相似。
关于如何解决这个问题的任何想法?谢谢。