@required annotation in javascript files

I am at the beginning of an attempt to create a JavaScript library for our RIA application at work. We currently have many JavaScript files with all the functions globally, and I would like to try to add some reasonable namespaces and context to our functions. Perhaps they fit into an object form.

I studied other open source libraries to help me figure out how best to build a library. I see many .js files with the following in one particular open source project.

/** * @required OpenLayers/Map.js */ 

eg.

Does this make any difference other than just a comment in the file? Is there a way to import other .js files into your main assembly using this annotation or an import statement like Java?

+4
source share
4 answers

This code uses JsDoc ( http://jsdoc.sourceforge.net/ ) or something similar to creating documentation from source code, most likely.

Javascript does not actually contain annotations.

+4
source

Select RequireJS . This is a downloader for JavaScript files and modules. It implements the CommonJS proposal .

+3
source

This is aa PHPDoc - a comment telling someone working with code that it will not work properly without OpenLayers/Map.js

+2
source

JavaDoc, the grandfather of all code documents / annotation systems for which all the others are output (I think):

http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html

+1
source

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


All Articles