[查看Angular的源代码时,似乎有一种确定注释样式的方法。快速google search不会显示要遵循的规则。有哪些准则?
例如,一个函数的注释如下:
/**
* when using forEach the params are value, key, but it is often useful to have key, value.
* @param {function(string, *)} iteratorFn
* @returns {function(*, string)}
*/
function reverseParams(iteratorFn) {
return function(value, key) { iteratorFn(key, value); };
}
它以斜杠(/)开头,后跟两个两个星号(*),并且每行上都有一个星号。在哪里定义?然后有几个@符号。 Javascript注释以/*
或//
开头,例如described here,因此此处涉及一些其他样式。我正在寻找对此的描述。...
[好,我要亲自回答。有人在给我this link的答案的评论中被删除了。多亏您,无论您是谁。我正在从此文档剪切和粘贴:
文档注释是用HTML编写的,并且必须在类,字段,构造函数或方法声明之前。它由两部分组成-一个描述,后跟块标签。在此示例中,块标记为@ param,@ return和@see。
/**
* Returns an Image object that can then be painted on the screen.
* The url argument must specify an absolute {@link URL}. The name
* argument is a specifier that is relative to the url argument.
* <p>
* This method always returns immediately, whether or not the
* image exists. When this applet attempts to draw the image on
* the screen, the data will be loaded. The graphics primitives
* that draw the image will incrementally paint on the screen.
*
* @param url an absolute URL giving the base location of the image
* @param name the location of the image, relative to the url argument
* @return the image at the specified URL
* @see Image
*/
public Image getImage(URL url, String name) {
try {
return getImage(new URL(url, name));
} catch (MalformedURLException e) {
return null;
}
}
注意:
段落标记分隔各个段落,如图所示。
更多示例,请参见Simple Examples。
因此行将不会换行,请将任何文档注释行限制为80个字符。
这是运行Javadoc工具后的上一个示例:
getImage
public Image getImage(URL url,
String name)
Returns an Image object that can then be painted on the screen. The url argument must specify an absolute URL. The name argument is a specifier that is relative to the url argument.
This method always returns immediately, whether or not the image exists. When this applet attempts to draw the image on the screen, the data will be loaded. The graphics primitives that draw the image will incrementally paint on the screen.
Parameters:
url - an absolute URL giving the base location of the image.
name - the location of the image, relative to the url argument.
Returns:
the image at the specified URL.
See Also:
Image