JsDoc链接到类的属性

时间:2014-12-14 15:52:10

标签: class properties reference jsdoc

我正在尝试使用在Windows上的NodeJS下托管的JsDoc 3.3.0来记录我的项目使用的模型。几乎所有东西都在工作,除了我似乎无法@link到类的属性。我的评论如下:

/**
 * Encapsulates all data concerning the speed, acceleration and braking characteristics
 * of a train or enemy.
 * @class speedModel
 * @property {Float} value The current real speed.
 * @property {Integer} target The speed we are attempting to reach.  Always greater than or equal to zero and less than or equal to {@link speedModel#max}.
 * @property {Integer} max The maximum value possible of {@link speedModel#target}.
 * @property {Float} acceleration The rate per tick at which {@link speedModel#value} approaches {@link speedModel#target} if it is greater.
 * @property {Float} deceleration The rate per tick at which {@link speedModel#value} approaches {@link speedModel#target} if it is lesser.
 */

奇怪的是,我可以@link to speedModel没有问题,如果我添加静态成员,我可以使用speedModel.nameOfMember链接到它们。我在这里关注文档:http://usejsdoc.org/tags-link.html

我做错了什么?

1 个答案:

答案 0 :(得分:1)

在对象中创建属性的doc,如下所示:

/**
 * Encapsulates all data concerning the speed, acceleration and braking characteristics
 * of a train or enemy.
 * @class
 * @property {Float} value The current real speed.
 * @property {Integer} target The speed we are attempting to reach.  Always greater than or equal to zero and less than or equal to {@link speedModel#max}.
 * @property {Integer} max The maximum value possible of {@link speedModel#target}.
 * @property {Float} acceleration The rate per tick at which {@link speedModel#value} approaches {@link speedModel#target} if it is greater.
 * @property {Float} deceleration The rate per tick at which {@link speedModel#value} approaches {@link speedModel#target} if it is lesser.
 */
function SpeedModel() {
  /** @property {Float} - The current real speed. */
  this.value = '';
};

/**
 * Converts kilometers per hour to miles per hour (see: {@link SpeedModel#value})
 * @param {Float} speed The speed in miles per hour
 * @return {Float} The speed in kilometers per hour
 */ 
function kmhToMph(speed) {
};