How can namespaces be documented in JavaScript with jsDoc?
Here is my attempt, is this right?
/**
* My special namespace
*
* @name my.namespace
* @namespace
*/
$namespace('my.namespace', /** @lends my.namespace **/ {
/**
* Foo - does something really neat...
* @function
*/
foo: function() {
}
});
Just to clarify, the above is used as follows:
my.namespace.foo();
Namespace refers to the programming paradigm of providing scope to the identifiers (names of types, functions, variables, etc) to prevent collisions between them. For instance, the same variable name might be required in a program in different contexts.
A namespace is a declarative region that provides a scope to the identifiers (the names of types, functions, variables, etc) inside it. Namespaces are used to organize code into logical groups and to prevent name collisions that can occur especially when your code base includes multiple libraries.
The namespace keyword is used to declare a scope that contains a set of related objects. You can use a namespace to organize code elements and to create globally unique types.
This feature is available in jsdoc3 micmath/jsdoc. The syntax of jsdoc3 is different to jsdoc-toolkit (jsdoc2)
The following example was by Michael jsdoc and pseudo-namespaces?
/**
* Document me.
* @namespace my
*/
/**
* My special namespace
* @namespace my.namespace
*/
$namespace('my.namespace', /** @lends my.namespace **/ {
/**
* Foo - does something really neat...
*/
foo: function() {
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With