在查看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); };
}
以斜杠(/)开头,后跟两个两个星号(*),每行都有一个星号。这定义在哪里?然后有几个@ -symbols。 Javascript评论以/*
或//
开头,described here,因此此处还涉及其他一些样式。我正在寻找关于这个的描述......
答案 0 :(得分:0)
好的,我将自己回答这个问题。有人在评论中给了我this link现在删除的答案。谢谢你,不管你是谁。我正在剪切和粘贴这个文档:
doc注释是用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
答案 1 :(得分:0)
看到这篇文章后,我尝试输入“ / **”,并在vs代码编辑器中得到了它 enter image description here
按Enter,我就这样 enter image description here
但是,我不知道它是否来自vs代码扩展。我认为这是一种标准的评论方式。谢谢。