Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@required annotation in javascript files

I am at the starting point of trying to build a JavaScript library for our RIA application at work. Currently we have lots of JavaScript files with functions all in global scope and I would like to attempt to put some reasonable namespace and context to our functions. Possibly putting them into object form.

I've been looking at other open source libraries to help me understand the best way to build a library. I see a lot of .js files with the following in one particular open-source project.

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

for example.

Does this have any meaning other than just being a comment in the file? Is there some kind of way to import other .js files into your main build with this annotation or an import statement like in Java?

like image 543
Peter Delaney Avatar asked Feb 02 '11 21:02

Peter Delaney


2 Answers

This code is using JsDoc (http://jsdoc.sourceforge.net/) or something similar to create documentation from the source code, most likely.

Javascript doesn't actually have annotations.

like image 65
James Black Avatar answered Sep 28 '22 05:09

James Black


Choose RequireJS. It is a JavaScript file and module loader. It implements the CommonJS proposal.

like image 40
viam0Zah Avatar answered Sep 28 '22 03:09

viam0Zah