java - 如何格式化 javadoc 注释中的标题?

标签 java javadoc

如何格式化 javadoc 注释中的标题,使其与 @param 的格式匹配, @return , 或 @throws .我不是问如何定义我自己的关键字,而是问如何使用与它们类似的粗体标题。

我试过了<h1></h1>但它在 Eclipse 的 Javadoc View 中看起来很糟糕,特别是尺寸要大得多。有替代品还是<h1></h1>怎么走?

/**
 * foo
 *
 * @param x foo
 * @return foo
 * @throws foo
 */
public int foo(int x) { return x; }

enter image description here

截图来自Eclipse。

更新

我不认为<strong>就足够了,因为它不添加换行符:

/**
 * Introdcution
 * 
 * <strong>Heading</strong>There is no line break.
 * <strong>Heading</strong>There is no line break.
 *
 * @param x foo
 * @return foo
 * @throws foo
 */

enter image description here

最佳答案

只需查看 JAVA API 生成的 Java Doc,例如SimpleDateFormat.parse (查看 HTML 源代码)。

他们使用 html 描述列表进行格式化,并使用 strong CSS 类来格式化术语。照样做:

/**
 * Introdcution
 * 
 * <dl>
 * <dt><span class="strong">Heading 1</span></dt><dd>There is a line break.</dd>
 * <dt><span class="strong">Heading 2</span></dt><dd>There is a line break.</dd>
 * </dl>
 *
 * @param x foo
 * @return foo
 * @throws foo
 */

看起来像这样:

JavaDoc screenshot

关于java - 如何格式化 javadoc 注释中的标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18054767/

相关文章:

java - 陷入 getInputStream 方法中

java - Android Javamail 附件抛出 java.lang.NullPointerException

java - Netty 大字符串,没有足够的可读字节

java - 如何在 Ant 的 javadoc 任务中链接第三方库

android - 如何在 gradle javadoc 任务中设置指向外部 AndroidX 引用的链接?

java - 如何判断两个小BufferedImage是否重复?

java - 如何在 Java AWT 应用程序中禁用系统键盘处理?

java - 无法查看 javadoc 信息。我如何解决它?

java - 尝试使用 Netbeans 8.0 在 javadoc 注释中的 {@code} block 中转义 "@"符号

java - 从 javadoc 中排除方法