我最近发现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
感谢。
答案 0 :(得分:13)
注释标记与JSDoc3类似,但并非所有JSDoc3标记都受支持。 JSdocs 3中缺少一些标签(它们在下面的列表中没有引用)。
你可以通过这种方式看到哪些是可用的:
它将显示支持的标记列表并帮助其语法(参数自动完成)。由于用户发布了多个错误报告,预计未来的Netbeans版本将支持更多标签。
以下是Netbeans 7.4支持的标签列表:
// Define argument type, name and description.
// This object adds onto a parent object.
// Identify the author of an item.
// This object uses something from another object.
// Use the following text to describe the entire class.
// Document an object as a constant.
// This function is intended to be called with the "new" keyword.
// This function member will be the constructor for the previous class.
// Document the default value.
// Document that this is no longer the preferred way.
// Describe a symbol.
// Type object is inherited from.
// A field.
// Describe a file.
// A function.
// [todo] Remove this from the final output.
// Document an inner object.
// Document properties on an object literal as if they belonged to a symbol with a given name.
// Inline tag - create a link.
// This symbol belongs to a parent symbol.
// Document the name of an object.
// Document a namespace object.
// Document the parameter to a function.
// This symbol is meant to be private.
// Document a property of an object.
// This symbol is meant to be public.
// This file requires a JavaScript module.
// Return.
// Document the return value of a function.
// Refer to some other documentation for more information.
// When was this feature added?
// Document a static member.
// Explain a syntax.
// Describe what errors could be thrown.
// Document the type of an object.
// Documents the version number of an item.
答案 1 :(得分:9)
答案 2 :(得分:0)
通常,文档标准由您的组织或客户提供。如果没有,我倾向于遵循类似于你在netbeans中找到的一般标准。
答案 3 :(得分:-4)
没关系。 /*
和*/
之间的所有内容都会被评论。 Netbeans通过在每一行添加*
使其看起来更好。点在Java
和Javascript
,您可以按/* ... */
- 多行或// ...
- 单行进行评论,而在CSS中,您只能使用{ {1}}。