【问题标题】:Javadoc closing tags [duplicate]Javadoc结束标签[重复]
【发布时间】:2016-02-20 15:25:48
【问题描述】:

阅读Oracle's Javadoc Documentation,注意到作者没有关闭<p>标签。

/**
 * The method used for creating the tree. Any structural 
 * modifications to the display of the Jtree should be done 
 * by overriding this method.
 * <p>
 * This method adds an anonymous TreeSelectionListener to 
 * the returned JTree.  Upon receiving TreeSelectionEvents, 
 * this listener calls refresh with the selected node as a 
 * parameter. 
 */
public JTree makeTree(AreaInfo ai){
}

文档说明:

如果文档注释中有多个段落,请使用&lt;p&gt; 段落标签分隔段落,如图所示。

在 Eclipse 中,Javadoc 的格式是正确的,但仅仅因为它有效,就意味着它是“正确的”吗?

【问题讨论】:

  • 我认为 Java 社区已接受您的 javadoc doc 标签不必是语法正确的 HTML。事实上,我只见过一个地方有人费心将&lt;/p&gt; 放在他们的 javadoc 中。

标签: java javadoc


【解决方案1】:

是的,没错。引用the specifications:

某些 HTML 元素类型允许作者省略结束标记(例如,P 和 LI 元素类型)

【讨论】:

  • 既然你打败了我的答案,我将添加 p 标签并指定它在某些情况下可能会省略其结束标签。 w3.org/TR/html-markup/p.htmlA p element’s end tag may be omitted if the p element is immediately followed by an address, article, aside, blockquote, dir, div, dl, fieldset, footer, form, h1, h2, h3, h4, h5, h6, header, hr, menu, nav, ol, p, pre, section, table, or ul element, or if there is no more content in the parent element and the parent element is not an a element.
  • 还有 JEP 224 关于将 HTML5 支持添加到 javadoc。
  • JEP 224 已交付,Java ≥9 可用。
猜你喜欢
  • 1970-01-01
  • 2014-04-22
  • 2012-03-20
  • 2017-10-04
  • 2011-01-16
  • 2021-06-13
  • 1970-01-01
  • 2013-11-26
  • 1970-01-01
相关资源
最近更新 更多