Netbeans javascript评论

时间:2011-06-13 16:21:07

标签: javascript netbeans comments

我最近发现Netbeans非常喜欢javascript注释,其格式如下:

/**
 * This is a sample comment
 * 
 * @param {Number} myParam info about this parameter
 * @return {String} Returns some sample string.
 */
function sample(info) { .. }

这似乎是Javadoc兼容的评论,但是呢?是否有某个资源将某些格式定义为可加性?此外,这种评论风格是否与其他IDE(如Eclipse?)相同?

编辑:我已上传此屏幕截图,以说明Netbeans如何解释@param和@return

enter image description here

感谢。

4 个答案:

答案 0 :(得分:13)

注释标记与JSDoc3类似,但并非所有JSDoc3标记都受支持。 JSdocs 3中缺少一些标签(它们在下面的列表中没有引用)。

你可以通过这种方式看到哪些是可用的:

  • 用/ **开始评论并按Enter;
  • 在评论类型@;
  • 使用Ctrl + Space(Netbeans)在@符号后调用代码完成。

它将显示支持的标记列表并帮助其语法(参数自动完成)。由于用户发布了多个错误报告,预计未来的Netbeans版本将支持更多标签。

以下是Netbeans 7.4支持的标签列表:

  • @argument // Define argument type, name and description.
  • @augments // This object adds onto a parent object.
  • @author // Identify the author of an item.
  • @borrows // This object uses something from another object.
  • @class // Use the following text to describe the entire class.
  • @constant // Document an object as a constant.
  • @constructor // This function is intended to be called with the "new" keyword.
  • @constructs // This function member will be the constructor for the previous class.
  • @default // Document the default value.
  • @deprecated // Document that this is no longer the preferred way.
  • @description // Describe a symbol.
  • @extends // Type object is inherited from.
  • @field // A field.
  • @fileoverview // Describe a file.
  • @function // A function.
  • @ignore // [todo] Remove this from the final output.
  • @inner // Document an inner object.
  • @lends // Document properties on an object literal as if they belonged to a symbol with a given name.
  • @link // Inline tag - create a link.
  • @memberof // This symbol belongs to a parent symbol.
  • @name // Document the name of an object.
  • @namespace // Document a namespace object.
  • @param // Document the parameter to a function.
  • @private // This symbol is meant to be private.
  • @property // Document a property of an object.
  • @public // This symbol is meant to be public.
  • @requires // This file requires a JavaScript module.
  • @return // Return.
  • @returns // Document the return value of a function.
  • @see // Refer to some other documentation for more information.
  • @since // When was this feature added?
  • @static // Document a static member.
  • @syntax // Explain a syntax.
  • @throws // Describe what errors could be thrown.
  • @type // Document the type of an object.
  • @version // Documents the version number of an item.

答案 1 :(得分:9)

这种评论风格适用于JSDoc。

它类似于JavaDoc但有一些差异。

您可以在https://github.com/jsdoc/jsdoc

了解更多信息

答案 2 :(得分:0)

通常,文档标准由您的组织或客户提供。如果没有,我倾向于遵循类似于你在netbeans中找到的一般标准。

答案 3 :(得分:-4)

没关系。 /**/之间的所有内容都会被评论。 Netbeans通过在每一行添加*使其看起来更好。点在JavaJavascript,您可以按/* ... */ - 多行或// ... - 单行进行评论,而在CSS中,您只能使用{ {1}}。