我有一个AngularJS工厂,我正试图生成使用Jsdoc的文档。逻辑如下:
(function (angular) {
/**
* @module factories
* @memberOf angular_module
*/
var factories = angular.module('factories');
/**
* @class BaseService
* @classdesc Base object
* @param {Object} $rootScope Root scope for the application.
*/
factories.factory('BaseService', ['$rootScope', function ($rootScope) {
var baseObject = (function () {
// Prototype
var basePrototype = {
_construct: function (args) {
},
publicMethod: function (args) {
}
};
// 'Private' methods
function initialise(args) {
}
function privateMethod(param) {
}
function setObjectProperties(o, properties) {
for (prop in properties) {
if (properties.hasOwnProperty(prop)) {
o[prop] = properties[prop];
}
}
}
//-----------------------------------------------
return {
create: function (args, properties) {
function obj() { }
obj.prototype = basePrototype;
var o = new obj();
setObjectProperties(o, properties);
// Call the base object 'constructor'
o._construct(args);
return o;
}
};
})();
return {
/**
* @function create
* @memberof! BaseService
* @description Creates a new object
*/
create: function (args, properties) {
return baseObject.create(args, properties);
}
};
}
]);
/**
* @class ChildService
* @classdesc Child object
* @extends BaseService
*/
factories.factory('ChildService', ['BaseService', function (BaseService) {
return BaseService.create({ 'someProperty': true }, {
/**
* @function childPublicMethod
* @description Child public method
*/
childPublicMethod: function () {
return this.publicMethod(123);
}
});
}]);
}(angular));在另一份文件中:
/**
* @namespace angular_module
*/我遇到的问题是,我想为BaseService.create方法生成文档,作为BaseService文档的一部分。类似地,我想在ChildService.childPublicMethod部分为ChildService函数生成文档。但是,目前没有为BaseService.create创建任何东西,ChildService.childPublicMethod的文档被添加到工厂模块中。我尝试使用@lends和@别名,以及各种模块/类名的组合,作为@memberof行的一部分,但是到目前为止,还没有给出想要的结果。收到的任何建议都很感激。
发布于 2015-04-15 03:54:11
我提出的解决办法如下:
(function (angular) {
/**
* @namespace factories
* @memberof angular_module
*/
var factories = angular.module('factories');
/**
* @class BaseService
* @classdesc Base object
* @param {Object} $rootScope Root scope for the application.
* @memberof angular_module.factories
*/
factories.factory('BaseService', ['$rootScope', function ($rootScope) {
var baseObject = (function () {
// Prototype
var basePrototype = {
_construct: function (config) {
},
/**
* @function publicMethod
* @description Creates a new object
* @memberof angular_module.factories.BaseService
*/
publicMethod: function (args) {
}
};
// 'Private' methods
function initialise(args) {
}
function privateMethod(param) {
}
function setObjectProperties(o, properties) {
for (prop in properties) {
if (properties.hasOwnProperty(prop)) {
o[prop] = properties[prop];
}
}
}
//-----------------------------------------------
return {
create: function (args, properties) {
function obj() { }
obj.prototype = basePrototype;
var o = new obj();
setObjectProperties(o, properties);
// Call the base object 'constructor'
o._construct(args);
return o;
}
};
})();
return {
/**
* @function create
* @description Creates a new object
* @memberof angular_module.factories.BaseService
*/
create: function (args, properties) {
return baseObject.create(args, properties);
}
};
}
]);
/**
* @class ChildService
* @classdesc Child object
* @memberof angular_module.factories
* @extends angular_module.factories.BaseService
*/
factories.factory('ChildService', ['BaseService', function (BaseService) {
return BaseService.create({ 'someProperty': true }, {
/**
* @function childPublicMethod
* @description Child public method
* @memberof ChildService
*/
childPublicMethod: function () {
return this.publicMethod(123);
}
});
}]);
}(angular));以下是一些变化:
真希望这能帮上忙。
https://stackoverflow.com/questions/29641096
复制相似问题