mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
feat(docs): add support for events
This commit is contained in:
parent
456c7f62c5
commit
08d09ecbaa
2 changed files with 22 additions and 2 deletions
|
|
@ -252,11 +252,14 @@ describe('ngdoc', function(){
|
|||
var methodB = new Doc({name: 'methodB', methodOf: 'angular.service.abc'});
|
||||
var propA = new Doc({name: 'propA', propertyOf: 'angular.service.abc'});
|
||||
var propB = new Doc({name: 'propB', propertyOf: 'angular.service.abc'});
|
||||
var docs = [methodB, methodA, propB, propA, parent]; // keep wrong order;
|
||||
var eventA = new Doc({name: 'eventA', eventOf: 'angular.service.abc'});
|
||||
var eventB = new Doc({name: 'eventB', eventOf: 'angular.service.abc'});
|
||||
var docs = [methodB, methodA, eventB, eventA, propA, propB, parent]; // keep wrong order;
|
||||
ngdoc.merge(docs);
|
||||
expect(docs.length).toEqual(1);
|
||||
expect(docs[0].id).toEqual('angular.service.abc');
|
||||
expect(docs[0].methods).toEqual([methodA, methodB]);
|
||||
expect(docs[0].events).toEqual([eventA, eventB]);
|
||||
expect(docs[0].properties).toEqual([propA, propB]);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ function Doc(text, file, line) {
|
|||
this.param = this.param || [];
|
||||
this.properties = this.properties || [];
|
||||
this.methods = this.methods || [];
|
||||
this.events = this.events || [];
|
||||
this.links = this.links || [];
|
||||
}
|
||||
Doc.METADATA_IGNORE = (function(){
|
||||
|
|
@ -217,6 +218,10 @@ Doc.prototype = {
|
|||
description: self.markdown(text.replace(match[0], match[4]))
|
||||
};
|
||||
self.properties.push(property);
|
||||
} else if(atName == 'eventType') {
|
||||
var match = text.match(/^([^\s]*)\s+on\s+([\S\s]*)/);
|
||||
self.type = match[1];
|
||||
self.source = match[2];
|
||||
} else {
|
||||
self[atName] = text;
|
||||
}
|
||||
|
|
@ -525,6 +530,18 @@ Doc.prototype = {
|
|||
dom.h('Example', property.example, dom.html);
|
||||
});
|
||||
});
|
||||
dom.h('Events', this.events, function(event){
|
||||
var signature = (event.param || []).map(property('name'));
|
||||
dom.h(event.type + ' ' +
|
||||
event.shortName + '(' + signature.join(', ') + ') on ' +
|
||||
event.source, event, function(){
|
||||
dom.html(event.description);
|
||||
event.html_usage_parameters(dom);
|
||||
self.html_usage_this(dom);
|
||||
|
||||
dom.h('Example', event.example, dom.html);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
parameters: function(dom, separator, skipFirst, prefix) {
|
||||
|
|
@ -717,7 +734,7 @@ function merge(docs){
|
|||
});
|
||||
|
||||
// merge into parents
|
||||
if (findParent(doc, 'method') || findParent(doc, 'property')) {
|
||||
if (findParent(doc, 'method') || findParent(doc, 'property') || findParent(doc, 'event')) {
|
||||
docs.splice(i, 1);
|
||||
} else {
|
||||
i++;
|
||||
|
|
|
|||
Loading…
Reference in a new issue