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
});
};
});
我能找到的最接近的匹配是:How to document a factory that returns a class in angular with ngdoc?。這沒有幫助,因爲我沒有「類」名稱來連接方法,因爲我沒有使用僞古典繼承。