简体   繁体   English

使用RequireJS和JSDoc3记录木偶模块

[英]Documenting a Marionette Module with RequireJS and JSDoc3

I'm finally taking some time to formally document my Marionette code, but I'm running into some issues with JSDoc3 and Marionette modules. 我终于花了一些时间来正式记录我的Marionette代码,但是我遇到了JSDoc3和Marionette模块的一些问题。

How would I go about documenting a Marionette module defined like this: 我该如何记录这样定义的Marionette模块:

//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! 谢谢!

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: Module1.js:

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

    /** @lends module:Module1 */

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

and View.js: 和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 在视图的@name中,.Module1 /不是必需的,但它使在文档网页中更容易找到
  • 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 在此示例中,itemView在技术上是私有的,因为它不会返回,但我希望能够在文档中找到它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM