【问题标题】:How to describe angular controller methods in documentation?如何在文档中描述角度控制器方法?
【发布时间】:2015-10-07 22:57:50
【问题描述】:

我无法描述控制器方法。我该怎么做?

/**
* @ngdoc controller
* @name works.controller:worksCtrl
* @requires $http
* @requires $element
* @function
*
* @description
* Description for works controller. All methods will be writen later
*/
var worksCtrl = function ($http, $element) {

    var ctrl = this;

    //how it do there? this not work
    /** 
        * @name initializeGrid
        * @function
        * @description
        * Description for initializeGrid
    */
    ctrl.initializeGrid = function (a) {
       //...
    }

    ctrl.getTemplate = function (workIndex) {
      //...

    }
    //...
};

我正在使用 ngdoc 来自动生成文档。但我不明白我做错了什么。

【问题讨论】:

    标签: angularjs documentation documentation-generation jsdoc ngdoc


    【解决方案1】:

    我从未使用过 ngdoc,但在寻找角度代码本身时,看起来您需要在文档中添加 @ngdoc method 标记以获取内部函数。例如,在 $locationProvider 内部:

      /**
       * @ngdoc method
       * @name $locationProvider#hashPrefix
       * @description
       * @param {string=} prefix Prefix for hash part (containing path and search)
       * @returns {*} current value if used as getter or itself (chaining) if used as setter
       */
      this.hashPrefix = function(prefix) {
        if (isDefined(prefix)) {
          hashPrefix = prefix;
          return this;
        } else {
          return hashPrefix;
        }
      };
    

    希望对你有帮助。

    【讨论】:

    • 这不是答案,但这有助于我找到解决方案。谢谢!
    • 不客气,我很高兴它以间接的方式提供帮助:)
    【解决方案2】:
    /**
    * @ngdoc function
    * @name initializeGrid
    * @methodOf works.controller:worksCtrl
    * @description This method initialize auto grid system for works
    * @private
    */
    
    ctrl.initializeGrid = function () {
         ...
    }
    

    这就是我需要的。)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-15
      • 2017-04-02
      • 2016-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-27
      相关资源
      最近更新 更多