cwilson1031 / jsdoc-toolkit

Automatically exported from code.google.com/p/jsdoc-toolkit
0 stars 0 forks source link

jsdoc-toolkit won't document CommonJS modules #313

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The CommonJS module pattern is based on keeping things away from the global, as 
this is considered to be bad practice. I've been writing an application for 
RequireJS, which implements the commonJS asyn modules specifications. They look 
something like this:

// MyModule.js
define(function () {
    function MyModule() {}
    return MyModule;
});

For some reason however, if I document MyModule, jsdoc toolkit (and also jsdoc 
btw) don't seem to document MyModule. I've tried adding @public (which in my 
mind should indicate that this part should be documented), I've tried creating 
documentation with private, I've tried a whole bunch of other tags. But none of 
these seem to tell jsdoc toolkit it should include my constructors in it's 
documentation.

I'm guessing this is because jsdoc seems to be doing something smart with 
scoping, but this very much get's in the way as I'm currently finding myself 
removing the define statement and just pretending everything is in the global.

Original issue reported on code.google.com by wi...@pangeadc.nl on 13 Jan 2011 at 1:36

GoogleCodeExporter commented 8 years ago
The @name tag is your friend.
http://code.google.com/p/jsdoc-toolkit/wiki/TagName

define(function () {
    /**
        @name MyModule
        @constructor
     */
    function MyModule() {
        /**
            @name MyModule#method
            @function
         */
        this.method = function(){
        }
    }
    return MyModule;
});

Original comment by micmath on 13 Jan 2011 at 3:36