JSDoc: what is the relationship between modules and namespaces

I had a problem 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(){} 

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

In addition, I cannot add another class to this class, because this class does not appear on the utils module tab:

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

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

+6
source share
1 answer

I played with him a bit, and I guess the modules in namespaces are a bit complicated. What worked for me was to define the utils module and the namespace that refers to it. The module is called utils , but not Game.utils , but in Game you can see a property that refers to it.

 /** * @namespace Game * @property {module:utils} utils */ /** * @module utils */ /** * Create a matrix * @class */ function Matrix(){} 
+4
source

Source: https://habr.com/ru/post/984738/


All Articles