mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-04-07 16:40:59 +00:00
@require in ngdoc now takes reason for dependency
This commit is contained in:
parent
d19c0ac6d3
commit
5b05c0de03
2 changed files with 24 additions and 17 deletions
|
|
@ -229,9 +229,16 @@ describe('ngdoc', function(){
|
|||
|
||||
describe('@requires', function() {
|
||||
it('should parse more @requires tag into array', function() {
|
||||
var doc = new Doc('@requires $service\n@requires $another');
|
||||
var doc = new Doc('@requires $service for \n`A`\n@requires $another for `B`');
|
||||
doc.ngdoc = 'service';
|
||||
doc.parse();
|
||||
expect(doc.requires).toEqual(['$service', '$another']);
|
||||
expect(doc.requires).toEqual([
|
||||
{name:'$service', text:'<p>for \n<code>A</code></p>'},
|
||||
{name:'$another', text:'<p>for <code>B</code></p>'}]);
|
||||
expect(doc.html()).toContain('<a href="#!angular.service.$service">$service</a>');
|
||||
expect(doc.html()).toContain('<a href="#!angular.service.$another">$another</a>');
|
||||
expect(doc.html()).toContain('<p>for \n<code>A</code></p>');
|
||||
expect(doc.html()).toContain('<p>for <code>B</code></p>');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -157,7 +157,11 @@ Doc.prototype = {
|
|||
description: self.markdown(text.replace(match[0], match[2]))
|
||||
};
|
||||
} else if(atName == 'requires') {
|
||||
self.requires.push(text);
|
||||
var match = text.match(/^([^\s]*)\s*([\S\s]*)/);
|
||||
self.requires.push({
|
||||
name: match[1],
|
||||
text: self.markdown(match[2])
|
||||
});
|
||||
} else if(atName == 'property') {
|
||||
var match = text.match(/^{(\S+)}\s+(\S+)(\s+(.*))?/);
|
||||
if (!match) {
|
||||
|
|
@ -185,6 +189,16 @@ Doc.prototype = {
|
|||
'This page is currently being revised. It might be incomplete or contain inaccuracies.');
|
||||
notice('deprecated', 'Deprecated API', self.deprecated);
|
||||
|
||||
if (self.ngdoc != 'overview') {
|
||||
dom.h('Description', self.description, dom.html);
|
||||
}
|
||||
dom.h('Dependencies', self.requires, function(require){
|
||||
dom.tag('code', function(){
|
||||
dom.tag('a', {href:"#!angular.service." + require.name}, require.name);
|
||||
});
|
||||
dom.html(require.text);
|
||||
});
|
||||
|
||||
(self['html_usage_' + self.ngdoc] || function(){
|
||||
throw new Error("Don't know how to format @ngdoc: " + self.ngdoc);
|
||||
}).call(self, dom);
|
||||
|
|
@ -251,8 +265,6 @@ Doc.prototype = {
|
|||
|
||||
html_usage_function: function(dom){
|
||||
var self = this;
|
||||
dom.h('Description', self.description, dom.html);
|
||||
dom.h('Dependencies', self.requires);
|
||||
dom.h('Usage', function(){
|
||||
dom.code(function(){
|
||||
dom.text(self.name);
|
||||
|
|
@ -269,8 +281,6 @@ Doc.prototype = {
|
|||
|
||||
html_usage_directive: function(dom){
|
||||
var self = this;
|
||||
dom.h('Description', self.description, dom.html);
|
||||
dom.h('Dependencies', self.requires);
|
||||
dom.h('Usage', function(){
|
||||
dom.tag('pre', {'class':"brush: js; html-script: true;"}, function(){
|
||||
dom.text('<' + self.element + ' ');
|
||||
|
|
@ -287,8 +297,6 @@ Doc.prototype = {
|
|||
|
||||
html_usage_filter: function(dom){
|
||||
var self = this;
|
||||
dom.h('Description', self.description, dom.html);
|
||||
dom.h('Dependencies', self.requires);
|
||||
dom.h('Usage', function(){
|
||||
dom.h('In HTML Template Binding', function(){
|
||||
dom.tag('code', function(){
|
||||
|
|
@ -319,8 +327,6 @@ Doc.prototype = {
|
|||
|
||||
html_usage_formatter: function(dom){
|
||||
var self = this;
|
||||
dom.h('Description', self.description, dom.html);
|
||||
dom.h('Dependencies', self.requires);
|
||||
dom.h('Usage', function(){
|
||||
dom.h('In HTML Template Binding', function(){
|
||||
dom.code(function(){
|
||||
|
|
@ -359,8 +365,6 @@ Doc.prototype = {
|
|||
|
||||
html_usage_validator: function(dom){
|
||||
var self = this;
|
||||
dom.h('Description', self.description, dom.html);
|
||||
dom.h('Dependencies', self.requires);
|
||||
dom.h('Usage', function(){
|
||||
dom.h('In HTML Template Binding', function(){
|
||||
dom.code(function(){
|
||||
|
|
@ -389,8 +393,6 @@ Doc.prototype = {
|
|||
|
||||
html_usage_widget: function(dom){
|
||||
var self = this;
|
||||
dom.h('Description', self.description, dom.html);
|
||||
dom.h('Dependencies', self.requires);
|
||||
dom.h('Usage', function(){
|
||||
dom.h('In HTML Template Binding', function(){
|
||||
dom.code(function(){
|
||||
|
|
@ -435,8 +437,6 @@ Doc.prototype = {
|
|||
|
||||
html_usage_service: function(dom){
|
||||
var self = this;
|
||||
dom.h('Description', this.description, dom.html);
|
||||
dom.h('Dependencies', this.requires);
|
||||
|
||||
if (this.param.length) {
|
||||
dom.h('Usage', function(){
|
||||
|
|
|
|||
Loading…
Reference in a new issue