diff options
Diffstat (limited to 'docs/src/ngdoc.js')
| -rw-r--r-- | docs/src/ngdoc.js | 104 |
1 files changed, 33 insertions, 71 deletions
diff --git a/docs/src/ngdoc.js b/docs/src/ngdoc.js index 8a20e64a..1a4f5d25 100644 --- a/docs/src/ngdoc.js +++ b/docs/src/ngdoc.js @@ -13,6 +13,11 @@ exports.scenarios = scenarios; exports.merge = merge; exports.Doc = Doc; +var BOOLEAN_ATTR = {}; +['multiple', 'selected', 'checked', 'disabled', 'readOnly', 'required'].forEach(function(value, key) { + BOOLEAN_ATTR[value] = true; +}); + ////////////////////////////////////////////////////////// function Doc(text, file, line) { if (typeof text == 'object') { @@ -385,69 +390,21 @@ Doc.prototype = { }); }, - html_usage_formatter: function(dom){ - var self = this; - dom.h('Usage', function(){ - dom.h('In HTML Template Binding', function(){ - dom.code(function(){ - if (self.inputType=='select') - dom.text('<select name="bindExpression"'); - else - dom.text('<input type="text" name="bindExpression"'); - dom.text(' ng:format="'); - dom.text(self.shortName); - self.parameters(dom, ':', false, true); - dom.text('">'); - }); - }); - - dom.h('In JavaScript', function(){ - dom.code(function(){ - dom.text('var userInputString = angular.formatter.'); - dom.text(self.shortName); - dom.text('.format(modelValue'); - self.parameters(dom, ', ', false, true); - dom.text(');'); - dom.text('\n'); - dom.text('var modelValue = angular.formatter.'); - dom.text(self.shortName); - dom.text('.parse(userInputString'); - self.parameters(dom, ', ', false, true); - dom.text(');'); - }); - }); - - self.html_usage_parameters(dom); - self.html_usage_this(dom); - self.html_usage_returns(dom); - }); - }, - - html_usage_validator: function(dom){ + html_usage_inputType: function(dom){ var self = this; dom.h('Usage', function(){ - dom.h('In HTML Template Binding', function(){ - dom.code(function(){ - dom.text('<input type="text" ng:validate="'); - dom.text(self.shortName); - self.parameters(dom, ':', true); - dom.text('"/>'); - }); - }); - - dom.h('In JavaScript', function(){ - dom.code(function(){ - dom.text('angular.validator.'); - dom.text(self.shortName); - dom.text('('); - self.parameters(dom, ', '); - dom.text(')'); + dom.code(function(){ + dom.text('<input type="' + self.shortName + '"'); + (self.param||[]).forEach(function(param){ + dom.text('\n '); + dom.text(param.optional ? ' [' : ' '); + dom.text(param.name); + dom.text(BOOLEAN_ATTR[param.name] ? '' : '="..."'); + dom.text(param.optional ? ']' : ''); }); + dom.text('>'); }); - self.html_usage_parameters(dom); - self.html_usage_this(dom); - self.html_usage_returns(dom); }); }, @@ -473,11 +430,11 @@ Doc.prototype = { dom.text('<'); dom.text(self.shortName); (self.param||[]).forEach(function(param){ - if (param.optional) { - dom.text(' [' + param.name + '="..."]'); - } else { - dom.text(' ' + param.name + '="..."'); - } + dom.text('\n '); + dom.text(param.optional ? ' [' : ' '); + dom.text(param.name); + dom.text(BOOLEAN_ATTR[param.name] ? '' : '="..."'); + dom.text(param.optional ? ']' : ''); }); dom.text('></'); dom.text(self.shortName); @@ -533,12 +490,18 @@ Doc.prototype = { dom.h('Events', this.events, function(event){ dom.h(event.shortName, event, function(){ dom.html(event.description); - dom.tag('div', {class:'inline'}, function(){ - dom.h('Type:', event.type); - }); - dom.tag('div', {class:'inline'}, function(){ - dom.h('Target:', event.target); - }); + if (event.type == 'listen') { + dom.tag('div', {class:'inline'}, function(){ + dom.h('Listen on:', event.target); + }); + } else { + dom.tag('div', {class:'inline'}, function(){ + dom.h('Type:', event.type); + }); + dom.tag('div', {class:'inline'}, function(){ + dom.h('Target:', event.target); + }); + } event.html_usage_parameters(dom); self.html_usage_this(dom); @@ -632,10 +595,9 @@ var KEYWORD_PRIORITY = { '.angular.Object': 7, '.angular.directive': 7, '.angular.filter': 7, - '.angular.formatter': 7, '.angular.scope': 7, '.angular.service': 7, - '.angular.validator': 7, + '.angular.inputType': 7, '.angular.widget': 7, '.angular.mock': 8, '.dev_guide.overview': 1, |
