KDoc中的表格?

时间:2018-04-28 08:02:39

标签: kotlin kdoc

我们的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 {
 ...
}

这使得(在使用Javadoc预览的Intellij中)很好地呈现出这样的东西:

enter image description here

现在我们想为我们的Kotlin数据类做同样的事情。阅读KDoc的文档,其中说:

  

对于内联标记,KDoc使用常规的Markdown语法,扩展为支持用于链接到代码中其他元素的简写语法。

所以我尝试使用Markdown语法创建表格:

/**
 * Changelog:
 *
 *| Version       | Description                 |
 *| ------------- | --------------------------  |
 *| 2             | Added field 'something'     |
 *| 3             | Added field 'somethingElse' |
 *
 */
data class MyKotlinDTO(..) { 
    ...
}

但这会呈现(再次使用Intellij预览版):

enter image description here

这看起来不像是一张桌子。

我还试过使用HTML表格,但这也不起作用。

问题

KDoc是否支持表格,如果支持,您如何创建表格?

2 个答案:

答案 0 :(得分:6)

目前KDoc不支持表格 - Github Youtrack已打开问题

有一些解决方法 - 您可以使用``(三重反引号)来包围文本以保留缩进和格式

答案 1 :(得分:1)

唯一的解决方法是使用Markdown Tables Generator生成表。例如,

enter image description here

然后将其粘贴到您的文档中,

enter image description here

相关问题