【问题标题】:JsDoc links to properties of classesJsDoc 链接到类的属性
【发布时间】:2015-02-12 18:42:08
【问题描述】:

我正在尝试使用在 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 到 speedModel,如果我添加静态成员,我可以使用 speedModel.nameOfMember 链接到它们。我在这里关注文档:http://usejsdoc.org/tags-link.html

我做错了什么?

【问题讨论】:

    标签: class properties reference jsdoc


    【解决方案1】:

    创建对象内部属性的文档,如下所示:

    /**
     * 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) {
    };
    

    【讨论】:

    • 感谢您的回答。问题是它不是一个真正的类——它只是一个模型,当从一个文件中导入时,它不是一个实际的 SpeedModel。也许类是错误的使用方式,我应该使用接口?
    • 如果更有意义,您可以创建一个 namespace 代替
    • 我想这在这种情况下最有意义;即使对象不是静态的,架构也是。感谢您的帮助!
    猜你喜欢
    • 2015-11-21
    • 2018-03-15
    • 2020-02-21
    • 2013-04-05
    • 1970-01-01
    • 2018-02-01
    • 2017-08-05
    • 2020-03-30
    • 1970-01-01
    相关资源
    最近更新 更多