JSDoc:模块和命名空间之间的关系是什么 [英] JSDoc: What is a relationship between modules and namespaces

查看:121
本文介绍了JSDoc:模块和命名空间之间的关系是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在理解联合中命名空间和模块的目的时遇到了问题。例如,我有一个类 Game.utils.Matrix 。我想注释游戏作为命名空间, utils 作为模块和矩阵作为一个班级:

I faced a problem with understanding the purpose of namespaces and modules in a union. For example I have a class Game.utils.Matrix. I want to annotate Game as a namespace, utils as a module and Matrix as a class:

/**
 * @namespace Game
 */

/**
 * @module utils
 * @memberOf Game
 */

/**
 * Create a matrix
 * @constructor
 */
function Matrix(){}

它创建了一个文档, Matrix 类的名称路径是 Game.utils~Matrix ,但是如果我按照模块链接,其名称路径是模块:utils 没有游戏名称空间前缀,如果我按照游戏链接,它不包含 utils 模块链接。

It creates a documentation and the name path of the Matrix class is Game.utils~ Matrix, but if I follow the Module link its name path is Module: utils without the Game namespace prefix, and if I follow the Game link it does not contain the utils module link.

此外,我无法在此模块中添加另一个类,因为此类未显示在 utils 模块选项卡中:

Moreover, I can't add another class to this module as This class is not shown in the utils module tab:

/**
 * Create Dictionary
 * @memberOf Game.utils
 * @constructor
 */
function Dictionary(){}

问题是:记录命名空间和模块的正确方法是什么以及是每个用例的用例吗?

The question is: what is the correct way to document namespaces and modules and what is the use case for each of them?

推荐答案

我玩了一下,我想在命名空间中有模块是一个有点棘手。对我有用的是定义一个模块 utils 和一个引用它的命名空间。该模块名为 utils 但是,不是 Game.utils 但是在游戏你可以看到一个链接到它的房产。

I played with it a bit and I guess having modules in a namespaces is a bit tricky. What worked for me is to define a module utils and a namespace which references it. The module is called utils however, not Game.utils but in Game you can see a property which links to it.

/**
 * @namespace Game
 * @property {module:utils} utils
 */

/**
* @module utils
*/

/**
 * Create a matrix
 * @class
 */
function Matrix(){}

这篇关于JSDoc:模块和命名空间之间的关系是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆