如何描述使用ngdocs提供函数集合的返回对象?

时间:2014-06-19 19:00:34

标签: javascript angularjs jsdoc

我正在尝试根据以下结构创建文档:

/**
* @ngdoc service
*
* @name module:resource
* @module module
* @ return {Object} The returned object
*/

angular.module('module').factory('resource', [
  function () {
   function Foo (param1) {
      //Do something with param1
      }

      return {

         Test: {
           /**
            * @ngdoc function
            * @name resource#theTest
            * @methodOf module:resource
            *
            * @description
            * Search to see if a study exists with the given protocol identifier
            * @param  {Object} params The param
            * @return {Object}        A Promise
            */
          theTest: function(param) {
                return functionFoo (param);
           },

           /**
            * @ngdoc function
            * @name resource#theTest1
            * @methodOf module:resource
            *
            * @description
            * Search to see if a study exists with the given protocol identifier
            * @param  {Object} params The param
            * @return {Object}        A Promise
            */
           theTest1: function(param) {
               return functionFoo (param)
           }
        }
    };
   }
]);

我想在文档中说的是服务'resource'返回一个返回函数集合的对象,但我找不到使用ngdocs执行此操作的方法。是否支持?

谢谢

1 个答案:

答案 0 :(得分:0)

我认为你不能指定'函数映射'唯一支持的类型是Function,object,string,number,... 但您可以在类中添加说明,如:

/*
 * @description
 * This class return 2 functions as describe below:
 * ```js
 *  {
 *      theTest {Function} This function do (...)
 *      theTest1 {Function} This function do (...)
 *  };
 * ```
 */
function Foo (param1) {

希望这会有所帮助