2016-08-12 2 views
2

ngdocを使用して 'ファクトリ関数'を返す '角度ファクトリ'を文書化するにはどうすればよいですか?具体的には、「ファクトリ関数」が作成するオブジェクトをどのように文書化しますか?ngdocを使ってファクトリ関数によって生成されたオブジェクトを角度で文書化するには?

下の実例では、ファクトリを使用してページオブジェクトを作成する方法を説明しましたが、ページオブジェクト自体の使用方法をどのように文書化しますか?

angular.module('fooRestClient').factory('page', function() { 

    var prototype = {}; 

    // Below I need to somehow link the methods a page object has to the 
    // factory's documentation. 

    /** 
    * @description Fetches the page at the specified index. 
    * 
    * @param {number} index - the index of the page to fetch 
    * 
    * @returns {object} a page object representing the page at the given index 
    */ 
    prototype.getPage = function (index) { 
     // returns a new page. 
    }; 

    // ... more useful methods. 

    /** 
    * @ngdoc service 
    * @type function 
    * @name fooRestClient:page 
    * @description 
    * A factory function for producing page objects.... 
    * 
    * @param {Number} index - The page index. 
    * @param {Number} size - The page size. 
    * @param {Number} total - The total number of pages. 
    * @param {Array} data - The contents of the page. 
    * @returns {object} A page object for the given resource 
    */ 
    return function page(index, size, total, data) { 
     return Object.create(prototype, { 
      index: index, 
      size: size, 
      total: total, 
      data: data 
     }); 
    }; 

}); 

私がSOで見つけることができるのは、How to document a factory that returns a class in angular with ngdoc?です。私は疑似古典的な継承を使用していないので、メソッドをリンクする "クラス"の名前がないので、これは役に立ちません。

答えて

0

期待どおりたぶんこの作品:

/** 
 
    * @ngdoc service 
 
    * @type function 
 
    * @name fooRestClient:page 
 
    * @description 
 
    * A factory function for producing page objects.... 
 
    * 
 
    * @param {Number} index - The page index. 
 
    * @param {Number} size - The page size. 
 
    * @param {Number} total - The total number of pages. 
 
    * @param {Array} data - The contents of the page. 
 
    * @returns {object} A {@link prototypeInstance|page object} for the given resource 
 
    */ 
 

 
    return function page(index, size, total, data) { 
 
     /** 
 
     * @ngdoc object 
 
     * @name prototypeInstance 
 
     * @description page object for the given resource 
 
     */ 
 
     return Object.create(prototype, { 
 
     /* 
 
     * @ngdoc object 
 
     * @name prototypeInstance#index 
 
     * @description index description 
 
     */ 
 
     index: index, 
 
     /* 
 
     * @ngdoc object 
 
     * @name prototypeInstance#size 
 
     * @description size description 
 
     */ 
 
     size: size, 
 
     /* 
 
     * @ngdoc object 
 
     * @name prototypeInstance#total 
 
     * @description total description 
 
     */ 
 
     total: total, 
 
     /* 
 
     * @ngdoc object 
 
     * @name prototypeInstance#data 
 
     * @description data description 
 
     */ 
 
     data: data 
 
     }); 
 
    };

私はその少し冗長を知っているが、それは私は物事

のこの種を行うに見つけた唯一の方法です
関連する問題