Javadoc 中应使用哪个标签作为段落分隔符?

发布于 2024-10-21 03:15:06 字数 119 浏览 5 评论 0原文

根据最佳实践,哪个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

倾听心声的旋律 2024-10-28 03:15:06

欢迎来到 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.

吃颗糖壮壮胆 2024-10-28 03:15:06

严格来说,自关闭

没有任何意义,因为

应该用于包含一个段落,即该段落应由

括起来。

然而
是一个“较低级别”标签,表示换行符。因此,语义上正确的指示段落的方法是使用

<p>This Foo is used to frobincate a {@link Baz}.</p>
<p>It is quite groovy!</p>

This Foo is used to frobincate a {@link Baz}.<br>
It is quite groovy!

视觉上

会导致行之间有更多空白,而 < 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>:

<p>This Foo is used to frobincate a {@link Baz}.</p>
<p>It is quite groovy!</p>

vs.

This Foo is used to frobincate a {@link Baz}.<br>
It is quite groovy!

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.

卸妝后依然美 2024-10-28 03:15:06

在 Java 8 中,单个起始元素 (

) 即可工作。

请注意,javadoc 不喜欢结束元素 (

)。

With Java 8, a single starting element(<p>) works.

Note that javadoc doesn't like the closing element (</p>).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文