Global exported functions

99 views
Skip to first unread message

Tim Statler

unread,
Mar 29, 2012, 8:11:22 PM3/29/12
to JSDoc Users
Hi,

I need to document several functions defined in a single JS file. Each
has the following pattern:

// functions.js
/**
* A function
*/
var a = exports.someFunction = function() {
return "foo";
};
/**
* Another function
*/
var b = exports.someOtherFunction = function(){
return "bar";
};

These are coded as modules, but they will be consumed as global
functions, not as required modules. I looked at the JSDoc3 modules
pattern page for inspiration
(http://usejsdoc.org/howto-commonjs-modules.html). The patterns there
generated prototypes in the output, which I don't want in this case.
Rather, I want to list each function under the global namespace.

This seems pretty basic so I'm probably missing something obvious.
Thanks for any help.

Tim

Michael Mathews

unread,
Mar 30, 2012, 3:24:49 AM3/30/12
to tim.s...@gmail.com, JSDoc Users
Anytime you find yourself battling to get the documentation to say something that your code doesn't, as in a method of exports that is really a global function, you should switch yourself into a mode where you just plan to provide a @name for all your doclets. You might find you can get away without a @name once in a while and that would be a bonus, but don't waste so much effort trying to avoid just writing what you want in your output.

// functions.js

/**
* @function someFunction
* @returns {string} foo


*/
var a = exports.someFunction = function() {
return "foo";
};

/**
* @function someOtherFunction
* @returns {string} bar


*/
var b = exports.someOtherFunction = function(){
return "bar";
};

Note that in JSDoc 3 you can either use a separate @name tag or put the @name after a tag that identifiers the @kind of thing you are documenting, so @function foo, @class foo, @method foo.qaz, @member foo.blat etc.

Michael Mathews
mic...@gmail.com

> --
> You received this message because you are subscribed to the Google Groups "JSDoc Users" group.
> To post to this group, send email to jsdoc...@googlegroups.com.
> To unsubscribe from this group, send email to jsdoc-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/jsdoc-users?hl=en.
>

Reply all
Reply to author
Forward
0 new messages