Javadoc 中应使用哪个标签作为段落分隔符?
根据最佳实践,哪个 HTML 标签更适合用于分解 javadoc 的段落/长部分?
是
还是
?为什么?
Which is the more appropriate HTML tag for breaking up paragraphs/long sections of javadoc so according to best practices?
Is it <p />
or <br />
? Why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
欢迎来到 HTML 3.2 的土地。
根据官方文档注释编写指南,分隔段落的正确方法是使用段落标签:
。查看格式部分中的第七个项目符号文档评论。
通常,我强烈建议不要使用这种旧的、过时的标记做法。然而,在这种情况下,有充分的理由破例。 Javadoc 工具(除非使用自定义 Doclet 进行彻底更新)会生成旧的、粗糙的、有些损坏的标记。浏览器被构建为向后兼容当今疯狂的旧标记,因此您顺从它是有意义的。使用
分隔段落将与 Javadoc 输出的其余部分保持一致。
Welcome to the land of HTML 3.2.
According to the official guide on writing doc comments, the correct way to separate paragraphs is with the paragraph tag:
<P>
. Take a look at the seventh bullet in the section on Format of a Doc Comment.Ordinarily, I would strongly recommend against using such old, outdated practices for markup. However, in this case, there's a decent reason to make an exception. The Javadoc tool (unless radically updated with custom Doclets) generates old, crufty, somewhat broken markup. Browsers have been built to be backwards-compatible with the crazy old markup of the day, so it makes sense for you to just go along with it. Your use of
<P>
to separate paragraphs will be in line with the rest of the Javadoc output.严格来说,自关闭
没有任何意义,因为
应该用于包含一个段落,即该段落应由
和
括起来。
然而
是一个“较低级别”标签,表示换行符。因此,语义上正确的指示段落的方法是使用:
与
视觉上
会导致行之间有更多空白,而 < code>
只会开始一个新行,不会引入任何主要空格。
Strictly speaking a self-closing
<p />
makes no sense, as<p>
should be used to contain a paragraph, i.e. the paragraph should be encased by<p>
and</p>
.<br>
however is a "lower level" tag that indicates a line break. So the semantically correct way to indicate paragraphs would be to use<p>
:vs.
Visually the
<p>
results in more whitespace between the lines, while a<br>
will just start a new line and not introduce any major whitespace.在 Java 8 中,单个起始元素 (
) 即可工作。
请注意,javadoc 不喜欢结束元素 (
)。
With Java 8, a single starting element(
<p>
) works.Note that javadoc doesn't like the closing element (
</p>
).