Question

I'm finally taking some time to formally document my Marionette code, but I'm running into some issues with JSDoc3 and Marionette modules.

How would I go about documenting a Marionette module defined like this:

//Module1.js
define([... , 'views'], function(..., 'views'){
    "usestrict";

    //Marionette Module definition:
    return function(...marionette module params...){
        ...
    }
}

and then hook it up in the docs to a view defined like this:

//views.js
define([...], function(...){
    "usestrict";

    var itemView = Marionette.ItemView.extend({
        ...
    };

    //Uses itemView in a region
    return Marionette.Layout.extend({
        ...
        //do stuff with itemView
        ...
    });
}

?

Thanks!

Was it helpful?

Solution

Ok, thanks to Louis I figured out how to get the module to be recognized. I was then able to mess around with it enough to get the view registered as a class to the module.

Module1.js:

/** @module Module1 */
define([... , 'views'], function(..., 'views'){
    "usestrict";

    /** @lends module:Module1 */

    //Marionette Module definition:
    return function(...marionette module params...){
        ...
    }
}

and View.js:

define([...], function(...){
    "usestrict";

    /**
    * @name module:Module1.Module1/Views/itemView
    * @constructor
    */
    var itemView = Marionette.ItemView.extend(
    /** @lends module:Module1.Module1/Views/itemView.prototype */
    {
        ...
    };

    /**
    * @name module:Module1.Module1/Views/layoutView
    * @constructor
    */
    return Marionette.Layout.extend(
    /** @lends module:Module1.Module1/Views/layoutView.prototype */
    {
        ...
        //do stuff with itemView
        ...
    });
}

A couple of notes:

  • In the @name for the views, the .Module1/ isn't really necessary, but it makes it easier to find in the doc webpage
  • The itemView is technically private in this example since it doesn't get returned but I want to be able to find it in the docs
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top