Preventing global variables in jsdoc output

I am currently documenting my JS files using jsdoc, but I am having problems. I have 2 files, file1.js and file2.js (and not their real names). Both of these files contain a number of functions that I have documented in jsdoc style. When I run jsdoc for both files at the same time, the output is a list of global functions with their descriptions. There is no difference between where the functions are actually located (whether in file1.js or file2.js ). Is there a way to create this distinction in order to give my documentation a better structure?

+4
source share
1 answer

You can use the @module tag in each file:

 /** * @module file1 */ 

You would use file2 for your other file. I assumed that your modules will have the same name as your files.

Then, when you want to access things in a module, you use the module: notation. Therefore, if your file1 module contains a class called foo . You should refer to it to mark the type of data that the function in another module returns with @returns {module:file1~foo} . The tilde designation is explained here . This simply indicates that foo is an "internal" member of the file1 module. (Making it a β€œstatic” member would be better in my opinion, but the current version of jsdoc is not up to the task for modules.)

+5
source

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


All Articles