【问题标题】:Document a constant using ngDoc使用 ngDoc 记录一个常量
【发布时间】:2014-09-29 14:14:54
【问题描述】:

如何使用 ngDoc 记录一个常量?我没有看到任何用于记录使用.constant 注册的值的特定角度文档,并且常量的 jsDoc 语法在通过 ngDoc 运行时似乎不会生成任何实际文档。

例如:

/** * @constant * @name WHITE * * @description * The color white! **/ module.constant( 'WHITE', '#fff' );

【问题讨论】:

    标签: angularjs jsdoc


    【解决方案1】:

    ngDocs 目前不提供记录常量的方法。正如您在其templating source code 中看到的那样。没有相关的html_usage_* 方法。

    我像这样记录常量,然后将 APP_CONFIG 显示为模块。

    /**
     * @ngdoc object
     * @name APP_CONFIG
     * @description
     *   constant...
     * @example
     * APP_CONFIG is injectable as constant (as a service even to .config())
     * <pre>
     * (...)    .config(function ($APP_CONFIG) {
     * </pre>
     */
    

    【讨论】:

    • 你知道如何记录一个 .run 函数吗?
    【解决方案2】:

    应该是@const

    /** @const */ var MY_BEER = 'stout';
    
    /**
     * My namespace's favorite kind of beer.
     * @const {string}
     */
    mynamespace.MY_BEER = 'stout';
    
    /** @const */ MyClass.MY_BEER = 'stout';
    
    /**
     * Initializes the request.
     * @const
     */
    mynamespace.Request.prototype.initialize = function() {
      // This method cannot be overridden in a subclass.
    };
    

    查看常量部分 http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml#Constants 和 cmets 部分 http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml?showone=Comments#Comments 了解更多信息

    【讨论】:

      猜你喜欢
      • 2015-06-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-29
      • 2015-11-20
      • 1970-01-01
      • 1970-01-01
      • 2014-08-20
      相关资源
      最近更新 更多