Javadoc Jsdoc 在 @param 和 @return 内容块之后写一些东西?

发布于 2024-09-06 03:39:13 字数 738 浏览 10 评论 0原文

你知道是否可以在@param和@return块之后写一些东西。 假设我想在参数/返回声明之后编写一段文本,与它们分开

看来 Javadoc 和 Jsdoc 都将您在 @param/@return 之后编写的任何内容附加到同一内容块中。

比方说,我希望文档显示如下:

function showUpperCaseString(string_to_show)
This function shows the input string in upper case and blah, blah, ...

Parameters:

   {string} string_to_show

Returns:

   {boolean} true if everything was ok, or false on failure

   It's important to notice that I would like to show this text NOT in the
   return contents. But the Javadoc, Jsdoc always attach everything to the last
   @param/@return block. Even if I use nexline <br> or <p> it goes new line but 
   still indented as if it was part of the last return block.

Do you know if it's possible to write something after the @param and @return blocks.
Let's say I want to write a piece of text after the parameters/return declarations, something that is separated from them.

It seems Javadoc and Jsdoc both attach whatever you write after an @param/@return in the same block of conetnts.

Let's say for instance I want documentation to be shown like this:

function showUpperCaseString(string_to_show)
This function shows the input string in upper case and blah, blah, ...

Parameters:

   {string} string_to_show

Returns:

   {boolean} true if everything was ok, or false on failure

   It's important to notice that I would like to show this text NOT in the
   return contents. But the Javadoc, Jsdoc always attach everything to the last
   @param/@return block. Even if I use nexline <br> or <p> it goes new line but 
   still indented as if it was part of the last return block.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

╰つ倒转 2024-09-13 03:39:13

由于 JavaDoc 注释的格式,您尝试做的事情无法完成。 JavaDoc 确实允许一些 HTML,所以我之前通过添加我自己的“注释”区域来解决这个问题。

/**
 * Brief summary of what the method does here.
 * 
 * <p>
 * <b> NOTE: An IllegalStateException will be thrown if 
 * the object has not been initialized. </b>
 * </p>
 * 
 * <p>
 * <b> NOTE: Some additional information here about when
 * an <code>IllegalStateException</code> is thrown. </b>
 * </p>
 * 
 * @param aUseDefaults
 *            information about the parameter goes here
 * 
 * @throws IllegalStateException
 *            when the object isn't in the correct state
 */

What you are trying to do can't be done due to the format of JavaDoc comments. JavaDoc does allow some HTML though so I have gotten around this previously by adding my own "notes" areas.

/**
 * Brief summary of what the method does here.
 * 
 * <p>
 * <b> NOTE: An IllegalStateException will be thrown if 
 * the object has not been initialized. </b>
 * </p>
 * 
 * <p>
 * <b> NOTE: Some additional information here about when
 * an <code>IllegalStateException</code> is thrown. </b>
 * </p>
 * 
 * @param aUseDefaults
 *            information about the parameter goes here
 * 
 * @throws IllegalStateException
 *            when the object isn't in the correct state
 */
场罚期间 2024-09-13 03:39:13

简短的回答,不,你不能这样做。

长答案,JavaDoc 的设计使得注释有两个部分:叙述自由形式部分和块部分。一旦开始使用任何块标签,它们仅由下一个块标签分隔。没有用于“结束”块部分的标记,因此无论您使用什么最终标记,直到注释末尾​​的文本都将与其关联。
也就是说,JavaDoc 标签的使用也有一个完善的约定,包括信息的排序。 (请参阅http://java.sun.com/j2se/javadoc/writingdoccomments/)。

我相信您能够实现您正在尝试的最接近的方法是使用 @see 标记链接到其中包含注释的 html 文件。

Short answer, No you can't do that.

Long answer, JavaDoc is designed such that a comment has two sections, the narraitve free form section, and the block section. Once you start using any of the block tags, they are only delimited by the next block tag. There is not a tag to 'end' the block section, so whatever the final tag you use, the text up to the end of the comment will be associated with it.
That said, there is also a well established convention for the usage of JavaDoc tags, including the ordering of the information. (see http://java.sun.com/j2se/javadoc/writingdoccomments/).

The closest that I believe you will be able to come to what you are attempting, is to use the @see tag to link to an html file with the notes in it.

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