MyTetra Share
Делитесь знаниями!
JSDoc - Документирование кода Javascript
Время создания: 13.07.2018 15:30
Текстовые метки: javascript doc
Раздел: Javascript

usejsdoc.org - описание требований к документированию кода Javascript.


Наиболее распространённые теги документирования (Wikipedia):


Tag

Description

@author

Developer's name

@constructor

Marks a function as a constructor

@deprecated

Marks a method as deprecated

@exception

Synonym for @throws

@exports

Identifies a member that is exported by the module

@param

Documents a method parameter; a datatype indicator can be added between curly braces

@private

Signifies that a member is private

@return

Documents a return value

@returns

Synonym for @return

@see

Documents an association to another object

@this

Specifies the type of the object to which the keyword "this" refers within a function.

@throws

Documents an exception thrown by a method

@version

Provides the version number of a library


Пример наиболее распространённых способов документирования:


/**

* Creates an instance of Circle.

*

* @constructor

* @this {Circle}

* @param {number} r The desired radius of the circle.

*/

function Circle(r) {

/** @private */ this.radius = r;

/** @private */ this.circumference = 2 * Math.PI * r;

}


/**

* Creates a new Circle from a diameter.

*

* @param {number} d The desired diameter of the circle.

* @return {Circle} The new Circle object.

*/

Circle.fromDiameter = function (d) {

return new Circle(d / 2);

};


/**

* Calculates the circumference of the Circle.

*

* @deprecated

* @this {Circle}

* @return {number} The circumference of the circle.

*/

Circle.prototype.calculateCircumference = function () {

return 2 * Math.PI * this.radius;

};


/**

* Returns the pre-computed circumference of the Circle.

*

* @this {Circle}

* @return {number} The circumference of the circle.

*/

Circle.prototype.getCircumference = function () {

return this.circumference;

};


/**

* Find a String representation of the Circle.

*

* @override

* @this {Circle}

* @return {string} Human-readable representation of this Circle.

*/

Circle.prototype.toString = function () {

return "A Circle object with radius of " + this.radius + ".";

};


Так же в этом разделе:
 
MyTetra Share v.0.53
Яндекс индекс цитирования