简体   繁体   中英

VS Code - How to use JSDoc to document a prototype methods and property

I've a piece of code like this:

//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

But I don't know how to comment the .prototype object to see, with IntelliSense, the description and possibly type of the properties or methods. I've tried before to searching on StackOverflow and on other sites, but nothing was realy helpfull. Sorry for bad english.

Use @memberof tag identifier. Please see documentation and example of usage: JSDoc @memberof

You may want to use @alias as well to exclude "prototype" from your documentation. The example and documentation of usage: JSDoc @alias

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM