Комментирование вложенной функции объекта с помощью @memberof, @name и @method с помощью JSDoc - PullRequest
0 голосов
/ 11 октября 2019

Согласно https://jsdoc.app/about-namepaths.html, метод экземпляра с именем «say». должно быть задокументировано так: Class # function.

В приведенном ниже коде мне интересно, правильно ли задокументирована функция scream (@name, @memberof и @method)? И должен ли я задокументировать, что scream () возвращает в комментарии animalActions, или и то, и другое? И все остальное выглядит хорошо с точки зрения комментариев?

/**
 *  @class Animals
 *  @classdesc class for animals.
 */

function Animals (name) {
/**
  *  @type {Object}
  *  @property {string} name This animals name.
*/
  this.name = name }

/**
 * Contains common animal functions.
 * @returns {Object} common animal functions.
 * @returns {string} animalActions.scream makes the animal scream.
*/
Animals.prototype.animalActions = function () {
  return {
    /**
    * @name Animals#animalActions.scream
    * @memberof Animals.prototype#animalActions
    * @method scream
    */
    scream: function () { return 'AAARGH!' },

    }
}
...