我正在使用 documentation package ,但无法弄清楚如何将它记录为类属性(不是通过 getter 和 setter 定义的)。

下面只为 SomeClass 生成类文档,但省略了 someProperty 文档。

/** 
 * SomeClass is an example class for my question. 
 * @class 
 * @constructor 
 * @public 
 */ 
class SomeClass { 
    constructor () { 
        this.someProperty = true  // how do I document this? 
    } 
 
    /** 
     * someProperty is an example property that is set to `true` 
     * @property {boolean} someProperty 
     * @public 
     */ 
} 

旁白: @constructor在 jsdoc 类上是 documentation thing .

请您参考如下方法:

将 JSDoc 移动到第一次定义它的构造函数中。

/** 
 * SomeClass is an example class for my question. 
 * @class 
 * @constructor 
 * @public 
 */ 
class SomeClass { 
    constructor () { 
        /** 
         * someProperty is an example property that is set to `true` 
         * @type {boolean} 
         * @public 
         */ 
        this.someProperty = true 
    } 
} 

我不确定是否有办法使用 documentation package 来完成它使用不涉及将 JSDoc 内联到构造函数中的方法。


评论关闭
IT干货网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!