【问题标题】:VS Code - How to use JSDoc to document a prototype methods and propertyVS Code - 如何使用 JSDoc 记录原型方法和属性
【发布时间】:2017-03-04 02:06:48
【问题描述】:

我有一段这样的代码:

//line 0

/**
 * Constructor of class Person
 * @class
 * @constructor
 * @param {string} name Name of person
 * @param {string} surname Surname of person 
 * @param {number} age Age of person 
 */
function Person(name, surname, age){
    this.name = name;
    this.surname = surname;
    this.age = age;
}


/** Optional for my project, MISSING JSDOC */
Person.prototype = {
    //..somethings..

    /** MISSING JSDOC */
    talk: function(){
        //..somethings..
    }, 

    /** MISSING JSDOC */
    walk: function(){
        //..somethings..
    }, 

    /** MISSING JSDOC */
    foo: function(){
        //..somethings..
        p.bar();
        //..somethings..
    }
};

/**
 * A shortcut to access to {@link Person} methods' more easly
 * @type {Object} p 
 */
var p = Person.prototype;

//something else

但我不知道如何评论 .prototype 对象以使用 IntelliSense 查看属性或方法的描述和可能的类型。 我之前尝试过在 StackOverflow 和其他网站上进行搜索,但没有任何帮助。 抱歉英语不好。

【问题讨论】:

    标签: javascript visual-studio-code jsdoc


    【解决方案1】:

    使用@memberof 标签标识符。请参阅文档和使用示例:JSDoc @memberof

    您可能还想使用@alias 从您的文档中排除“原型”。使用示例及文档:JSDoc @alias

    【讨论】:

    • @memberof 无法与 vscode salsa/intellisense 配合使用,并且未列在 typescript 支持的 jsdoc 标签中
    猜你喜欢
    • 1970-01-01
    • 2015-02-05
    • 2017-11-20
    • 2018-12-30
    • 2015-04-15
    • 1970-01-01
    • 1970-01-01
    • 2021-12-01
    • 2018-02-01
    相关资源
    最近更新 更多