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?です。私は疑似古典的な継承を使用していないので、メソッドをリンクする "クラス"の名前がないので、これは役に立ちません。