最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to reference a @class in another file with JSdoc? - Stack Overflow

programmeradmin1浏览0评论

E.g. MyClass.js

/**
 * @class
 * @name module:Bar
 * @param {number} a1
 * @param {string} a2
 */
function Bar(a1, a2){}

And, in another file:

/** @type module:Bar.constructor */ // made up syntax
var Bar = require("./MyClass.js");

Re-defining @class works but it's not convenient:

/**
 * @class
 * @name module:Bar
 * @param {number} a1
 * @param {string} a2
 */
var Bar = require("./MyClass.js");

How do I do it?

E.g. MyClass.js

/**
 * @class
 * @name module:Bar
 * @param {number} a1
 * @param {string} a2
 */
function Bar(a1, a2){}

And, in another file:

/** @type module:Bar.constructor */ // made up syntax
var Bar = require("./MyClass.js");

Re-defining @class works but it's not convenient:

/**
 * @class
 * @name module:Bar
 * @param {number} a1
 * @param {string} a2
 */
var Bar = require("./MyClass.js");

How do I do it?

Share Improve this question asked Oct 19, 2016 at 9:08 WesWes 4,3364 gold badges26 silver badges46 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

The class name alone should be enough.

/**
 * @type module:Bar
 */
var Bar = require("./MyClass.js");

You should use @alias instead of @name:

Warning: By using the @name tag, you are telling JSDoc to ignore the surrounding code and treat your documentation ment in isolation. In many cases, it is best to use the @alias tag instead, which changes a symbol's name in the documentation but preserves other information about the symbol.

/**
 * @class
 * @alias module:Bar
 * @param {number} a1
 * @param {string} a2
 */
function Bar(a1, a2){}
发布评论

评论列表(0)

  1. 暂无评论