Tables in KDoc?

*爱你&永不变心* 提交于 2019-12-30 09:49:07

问题


We usually have changelog in our Java DTO's that consists of a table defined in 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 {
 ...
}

This renders (in Intellij using Javadoc preview) nicely into something like this:

Now we want to do the same thing for our Kotlin data classes. Reading up on the docs of KDoc where it says:

For inline markup, KDoc uses the regular Markdown syntax, extended to support a shorthand syntax for linking to other elements in the code.

So I've tried to create a table using Markdown syntax:

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

But this renders (again using Intellij preview):

Which doesn't look like a table.

I've also tried just using an HTML table but that doesn't work either.

Question

Does KDoc support tables and if so how do you create one?


回答1:


Currently KDoc does not support tables - there are issues opened on Github and Youtrack

There is some kind of workaround - you can surround text with ``` (triple backticks) to keep indentations and formatting




回答2:


The only workaround is to generate a table with Markdown Tables Generator. For example,

Then paste into your documentation,



来源:https://stackoverflow.com/questions/50074296/tables-in-kdoc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!