Allow custom events and do not collect events from methods

This commit is contained in:
Andreas Hocevar
2014-05-15 20:25:26 +02:00
parent 0d10314d4f
commit a75d944311
2 changed files with 18 additions and 13 deletions
+2 -6
View File
@@ -29,15 +29,11 @@ exports.handlers = {
event = doclet.fires[j].replace('event:', ''); event = doclet.fires[j].replace('event:', '');
if (events[event]) { if (events[event]) {
fires.push.apply(fires, events[event]); fires.push.apply(fires, events[event]);
} else {
fires.push(doclet.fires[j]);
} }
} }
doclet.fires = fires; doclet.fires = fires;
} else {
eventClass = classes[doclet.longname.split('#')[0]];
if (!eventClass.fires) {
eventClass.fires = [];
}
eventClass.fires.push.apply(eventClass.fires, doclet.fires);
} }
} }
} }
+16 -7
View File
@@ -57,18 +57,27 @@ var self = this;
<h5>Fires:</h5> <h5>Fires:</h5>
<ul><?js fires.forEach(function(f) { <ul><?js fires.forEach(function(f) {
var parts = f.split(/#?event:/); var parts = f.split(/#?event:/);
var type = parts.pop();
var eventClassName = parts[0];
parts = type.split(' ');
type = parts.shift();
var description = parts.length ? parts.join(' ') : '';
var eventDoclet = self.find({longname: f})[0];
if (eventDoclet && !description && eventDoclet.description) {
description = eventDoclet.description.replace(/<[^>]*>/g, '');
}
?> ?>
<li><?js var eventDoclet = self.find({longname: f})[0]; ?> <li>
<code><?js= self.linkto(f, parts[1]) ?></code> <code><?js= self.linkto(f, type) ?></code>
<?js if (parts[0]) { <?js if (eventClassName) {
var eventClass = self.find({longname: parts[0]})[0]; var eventClass = self.find({longname: eventClassName})[0];
if (eventClass) { ?> if (eventClass) { ?>
(<?js= self.linkto(eventClass.longname) ?>) (<?js= self.linkto(eventClass.longname) ?>)
<?js } ?> <?js } ?>
<?js } ?> <?js } ?>
<?js if (eventDoclet && eventDoclet.description) { ?> - <?js if (description) { ?> -
<?js= (eventDoclet ? self.partial('stability.tmpl', eventDoclet) : '') ?> <?js= self.partial('stability.tmpl', eventDoclet || (data.stability ? data : {stability: 'experimental'})) ?>
<?js= eventDoclet.description.replace(/<[^>]*>/g, '') ?> <?js= description ?>
<?js } ?> <?js } ?>
</li> </li>
<?js }); ?></ul> <?js }); ?></ul>