Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local var definition and exports in RequireJS module #49

Closed
danrzeppa opened this issue Oct 14, 2011 · 3 comments
Closed

Local var definition and exports in RequireJS module #49

danrzeppa opened this issue Oct 14, 2011 · 3 comments
Labels
Milestone

Comments

@danrzeppa
Copy link

Sometimes in RequireJS modules I define a local variable in the same statement that exports a function. This appears to confuse JSDoc as it does not recognize the exported symbol as being exported.

File1

/** @exports file1 */
define(function(){
  var exports={}

  /** @constructor */
  var someObject = exports.someObject = function() {}
  someObject.prototype.whatever=function() {}

  return exports
})

JSDoc cannot resolve the reference to module:file1.someObject in the @augments tag in

File 2

/** @exports file2 */
define(function(){
  var exports = {}
  var file1 = require("./file1")

  /**
  * @constructor
  * @augments module:file1.someObject
  */
  exports.otherObject = function() {}

  return exports
})

This is not a critical, or truly breaking issue since the same thing can be accomplished via

  /** @constructor */
  exports.someObject = function() {}
  var someObject = exports.someObject

But it would be nice if at some point it was supported.

@micmath
Copy link
Contributor

micmath commented Oct 14, 2011

Another way to do it is

var someObject =
/**
    @constructor
*/
exports.someObject = function() {
}

But in general the doc comment must appear immediately before the thing it documents (unless you provide a @name and then it can appear anywhere you please).

@jannon
Copy link
Contributor

jannon commented Mar 16, 2012

This might be a good candidate for a plugin. I'll try to look into the possibilities. For now, it's going into the 'future' bucket

@micmath
Copy link
Contributor

micmath commented May 30, 2012

I'm closing this since there is already two ways to do what the poster asks: use @name or split the assignment on two lines so the comment appears immediately before the thing being documented. This is already working as designed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants