Documenting prototype property and method with JSDoc-3.3.0-alpha5

1,204 views
Skip to first unread message

Riko Nagatama

unread,
Jun 12, 2014, 12:07:42 AM6/12/14
to jsdoc...@googlegroups.com

I have a class named FileDownloader and I've tried documenting it, but the properties and method declared using prototype aren't generated in the output file.

As stated on the title, I use jsdoc 3.3.0-alpha5.

Here's the code:

/**
 * @class
 * @memberOf module:utils
 */
FileDownloader = function() {};    
/**
 * @type {Boolean}
 */
FileDownloader.prototype.overwrite = false;
/**
 * @type {String}
 */
FileDownloader.prototype.dir = config.dealImagePath;    
/**
 * @param {String} url
 * @param {Function} done
 * @param {Object} done.err
 * @param {String} done.file
 */
FileDownloader.prototype.download = function(url, done) {
    //...
};

Here is the generated document:

new FileDownloader()
    | Source: path/to/file.js

Any idea?

Perry Smith

unread,
Jun 29, 2014, 1:30:46 PM6/29/14
to Riko Nagatama, jsdoc...@googlegroups.com
Two thoughts:

First: see what you get if you remove the @memberOf line.  Maybe that is confusing things?

Second: I get this style to work just fine for me:

FileDownloader.prototype = {
/**
 * @type {Boolean}
 */
  overwrite: false,

/**
 * @type {String}
 */
  dir: config.dealImagePath,

/**
 * @param {String} url
 * @param {Function} done
 * @param {Object} done.err
 * @param {String} done.file
 */
  download: function(url, done) {
    
  //...
  };
};


--
You received this message because you are subscribed to the Google Groups "JSDoc Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsdoc-users...@googlegroups.com.
To post to this group, send email to jsdoc...@googlegroups.com.
Visit this group at http://groups.google.com/group/jsdoc-users.
For more options, visit https://groups.google.com/d/optout.

Riko Nagatama

unread,
Jun 30, 2014, 11:29:23 PM6/30/14
to jsdoc...@googlegroups.com, kanat...@gmail.com
If I remove @memberOf line, using 3.3.0-alpha9 it will output the prototype properties and methods.
But how can I include this class to module:utils without @memberOf?

Perry Smith

unread,
Jul 1, 2014, 11:55:40 AM7/1/14
to Riko Nagatama, jsdoc...@googlegroups.com
I claim to not know what I'm doing :-)  So take my ideas with caution.

Does module:utils show up in the output that is produced otherwise?  The reason I ask:


I don't see : as a method to separate names.

Last, I had good luck with @alias.  You might toy around with that.

Riko Nagatama

unread,
Jul 1, 2014, 9:23:48 PM7/1/14
to jsdoc...@googlegroups.com, kanat...@gmail.com
Yeah it show up in the output, which contains FileDownloader and some other classes.

I use module instead of namespace because FileDownloader was made for node.js, and not for the browser.
So I thought it will be confusing using namespace because in node.js you can just require the module and name it whatever you want.

Let's say I give FileDownloader a utils namespace, but I don't really use namespace in node.js. I want to declare the variable without namespace like this:
var FileDownloader = require('./utils/FileDownloader');

not like this:
var utils.FileDownloader = require('./utils/FileDownloader');

I don't know if I do it right, but maybe a directory structure could help explain what I'm trying to do.
Here's the directory structure of my project:

lib
--utils
----FileDownloader.js
----OtherUtils.js
index.js


I want to require lib/utils/FileDownloader.js to index.js and use it there.
So what do you think? Am I right to use module or should I just use namespace?
Reply all
Reply to author
Forward
0 new messages