我正在使用documentation包,但无法弄清楚如何将其记录到文档类属性中(未通过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
*/
}
Run Code Online (Sandbox Code Playgroud)
@constructor顺便说一句:jsdoc类上的documentation东西。
Rol*_*olf 10
您可以在类中声明属性,并使用 @type 为其声明类型。在 VSCode 1.70.2 中使用纯 ECMAScript 模块工作。
class Foo {
/**
* Some bary data
* @type { BarClass }
*/
bar;
}
let f = new Foo();
f.bar; // Intellisense can tell you type and purpose
Run Code Online (Sandbox Code Playgroud)
另一种方法是在类文档中声明它们,如下所示:
/**
* Class definition
* @property {type} propName - propriety description
* ...
*/
class ClassName {
constructor () {...}
...
}
Run Code Online (Sandbox Code Playgroud)
将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
}
}
Run Code Online (Sandbox Code Playgroud)
我不确定是否有一种方法可以通过不使用将JSDocs内联到构造函数中的方法来完成该documentation程序包。
| 归档时间: |
|
| 查看次数: |
2088 次 |
| 最近记录: |