在aptana3中使用scriptDoc

在aptana中支持scriptDoc语法,并能够根据scriptDoc启用输入辅助。

scriptDoc 2.0 参考
简介:
这里介绍scriptDoc2.0的标签,一些标签会有一些同义词,再用的时候可以根据个人喜好选择使用。
每一个标记包括以下的信息:
概述
句法(Syntax)
这个标记的作用
详细解释
列子

@alias
概述 :类 Class 或者函数 function的ID
句法(Syntax):@alias fooBar
这个标记的作用 : 标识一个类或者函数,可以作为类或者函数的简称
例子:
/**
* Returns a function that will return a number one greater than the previous returned value, starting at n.
* @alias fooBar
* @alias FOO.Lib.fooBar
* @param {Object} n Number to start with. Default is 1.
* @return {Function) Returns a function that will return a number one greater than the previous returned value.
*/
fooBar: function (n/* = 1 */) {
if (arguments.length === 0) {
n = 1;
}
return function () {
return n++;
};
},

@author
概述 :显示作者信息
句法(Syntax):@author Author-name [email]
这个标记的作用 : 显示作者信息
例子:
/**
* @projectDescription Joe Smith's wonderful JavaScript library.
*
* @author Joe Smith jsmith@company.com
* @version 0.1
*/

@classDescription
概述 :对class的描述
句法(Syntax):@classDescription Description
这个标记的作用 : 概述类的信息(在合适的情况下)
例子:
这个例子给出了一个基本的Shape类的doc
/**
* Create a new instance of Shape.
*
* @classDescription This class creates a new Shape.
* @return {Shape} Returns a new Shape.
* @type {Object}
* @constructor
*/
function Shape() {
}

@constructor
概述 :显示这个函数作为构造函数(constructor)
用于(Applies to): function
句法(Syntax):@constructor
这个标记的作用 : 在面向对象编程的时候,表示一个function作为构造函数存在
例子:可以用上面同样的例子举例 @classDescription
/**
* Create a new instance of Shape.
*
* @classDescription This class creates a new Shape.
* @return {Object} Returns a new Shape object.
* @constructor
*/
function Shape() {
}

@deprecated
概述 :说明一个函数或者属性被弃用
用于(Applies to): function 或者 属性(property)
句法(Syntax):@deprecated
这个标记的作用 : 用来说明某一个函数或者属性被弃用,通常在升级和重构的时候使用
例子:
/**
* This function gets a foo by name.
* @param {Object} fooName Name of the foo to retrieve.
* @return {Object} Returns a new foo.
* @deprecated
*/

@example
概述 :给出例子
句法(Syntax):@example Example-code
这个标记的作用 : 为已经添加注释的代码书写使用例子,可以添加空格和html标记
例子:这个例子说明了参数中layerID以及direction的用法,并且使用了@example给出了使用例子。如果使用
HTML的标记来格式化描述,使用{code}{code}格式化。
例子中使用了@remark标记给出了更多的描述
/**
* This function moves a layer in the specified direction.
* @param {String} layerID The ID for the layer to be moved.
* @param {String} direction The direction for the layer to be moved.
* @param {Number} number Number of pixels to move the layer.
* @remarks The direction argument can be "right", "left", "up", or "down".
* You cannot move the layer beyond the boundaries of the browser window.
* @example Using the move function
* This example uses the move function to move myLayer to the right by 50 pixels.
* move(myLayer, right, 50)
* /
function move(layerID, direction, number)

@exception
概述 :描述函数的exception
用于(Applies to): function
句法(Syntax):@exception {Exception} Exception-description
这个标记的作用 : 用来说明函数产生的任何的exception,可以在一个块中描述多个exception
例子:
这个例子中抛出了MemoryException 和一个 GeneralShapeException
/**
* This function creates a new Shape object.
*
* @exception {MemoryException} Throws a memory exception if out of memory.
* @exception {GeneralShapeException} Throws a general shape exception if the object is not a shape.
* @return {Object} Returns a new shape object.
*/

@id
概述 :标识一个函数或者属性
句法(Syntax):@id identifierName
这个标记的作用 : 用来将代码和外部的@soc file链接起来,需要同时在代码块和文档中加入此标识
例子:
在代码中可以使用如下的内联注释(inline @id)
/** @id */
function foo() {
alert("Foo!");
}


@inherits
概述 :表示一个函数继承自其他函数
用于 :function
句法(Syntax):@inherits _functionNameA_
@inherits _functionNameB_
或者
@inherits _functionNameA_, _functionNameB_
这个标记的作用 : 在javascript的面向对象编程中,标识其父类
例子:
下面的例子标识了bar继承自foo
function foo() {
}

/** @inherits foo */
function bar() {
}

@internal
概述 :标识一个函数或者属性不能够被Content Assist使用
用于 :function 或者 属性(Property)
句法(Syntax):@internal
这个标记的作用 : 要注意这个概念和“内部”或者“私有”的区别,这个标识只是不让Content Assist发现它
例子:
/**
* @internal
*/

@memberOf
概述 :表示函数或者属性是另一个class的成员函数或者属性
用于 :function 或者 属性(Property)
句法(Syntax):@memberOf Class
这个标记的作用 : 这个表示函数或者属性是成员函数或者属性,注意和@internal的区别
例子:
/**
* @memberOf fooBar
*/
function getFoo(){
}

@method
概述 :表示一个函数是被其他类使用的方法
用于 :function
句法(Syntax):@method
这个标记的作用 : 表示一个函数是被其他类使用的方法,和@memberOf相比,@method更侧重于通用的工具方法
例子:
/**
* @method
*/

@namespace
概述 :描述一个库文件(library file)的命名空间
用于 :file
句法(Syntax):@namespace namespaceName
这个标记的作用 : 可以通过@namespace为当前库文件和外部注释文档(external .sdoc file)建立链接
例子:下面的例子展示了一个通过@namespace注释的例子,这个注释同时出现在库文件和外部注释文档的头部
/**
* @namespace snazzyLib.ajax
*/

@param
概述 :描述参数信息
用于 :function
句法(Syntax):@param {Type[, Type, _.]} [Parameter] Parameter-Description
这个标记的作用 : 给出每一个参数的信息,在大括号中描述数据类型,如果参数是可选的,使用[]
例子:
一个标准的例子:
/**
* @param {String} myDog The name of the dog.
*/
可选参数的例子:
/**
* @param {String, Date} [myDate] Specifies the date, if applicable.
*/
下面的例子展示了一个参数可以是一个或多个String
/**
* @param {String} ... Takes one or more dog parameters.
*/

@private
概述 :表示一个类或者函数是私有的
用于 :function 或者属性
句法(Syntax):@private
这个标记的作用 : 使用@private标记标识一个类或者函数是私有的。ScriptDoc在输出的时候不会
包含私有的类或者函数除非运行ScriptDoc的时候使用--private命令。
例子:
/**
* This function creates a new foo.
* @private
* @return {Object} Returns a foo.
*/

@projectDescription
概述 :对一个javascript文件进行描述
用于 :file
句法(Syntax):@projectDescription Description
这个标记的作用 : 在一个javascript file中使用其作为第一个标记,这个标记表示整个文档属于一个project的一部分
例子:
这个例子给出了@projectDescription 以及@author @version
/**
* @projectDescription This library contains a lot of classes and functions.
*
* @author Joe Smith jsmith@company.com
* @version 0.1
*/

@property
概述 :表示一个成员是一个类的实例的属性
用于 :file
句法(Syntax):@property {Type[, Type, _.]}
这个标记的作用 : 表示下述的成员是一个类的实例的属性
例子:
这个例子描述了myProperty这个String对象是MyClass的属性
/**
* This is a property of class MyClass
*
* @alias MyClass.myProperty
* @property {String}
*/

@return
概述 :描述函数的返回值
用于 :function
句法(Syntax):@return {Type[, Type, _.]} Returns-Description
这个标记的作用 : 描述函数的返回值
例子:
/**
* @return {Object} Returns a new foo object.
*/

@see
概述 :注释参照另一个相似的类或者函数
用于 :
句法(Syntax):@see Class|#Function|Class#Fuction
这个标记的作用 :注释参照另一个相似的类或者函数,可以是在同一个类中的函数,也可以是不同的类
例子:
同一个函数关联
/**
* @see #foo
*/
也可以同一个类关联
/**
* @see fooBar
*/
或者同一个类中的函数关联
/**
* @see fooBar
*/

@since
概述 :描述从哪一个版本开始起这个库、function、或者属性变得可用的
用于 :file、function、property
句法(Syntax):@since Version-number
这个标记的作用 : 描述从哪一个版本开始起这个库、function、或者属性变得可用的
例子:
这个例子结合了@projectDescription, @author, @version, @sinse,这样的注释块放到文档的最上方
/**
* @projectDescription This library contains a lot of classes and functions.
*
* @author Joe Smith jsmith@company.com
* @version 1.1
* @since 1.0
*/

@type
概述 :描述一个属性是什么类型
用于 :属性
句法(Syntax):@type {Type}
这个标记的作用 : 描述一个属性是什么类型
例子:
/**
* This property describes what type of shape an object is.
* @type {Object} This property describes what type of shape an object is.
*/

@version
概述 :描述一个javascript文档或者一个类的版本号
句法(Syntax):@version Version-Number
这个标记的作用 : 描述一个javascript文档或者一个类的版本号
例子:
/**
* @projectDescription A description of the file ahead
*
* @author Joe Smith jsmith@company.com
* @version 0.1
*/

posted on 2011-12-13 18:16  云上漫步  阅读(114)  评论(0)    收藏  举报