mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
fix(ngdocs): fix gen_docs.sh
This commit is contained in:
parent
5f92d4144e
commit
5a34464198
5 changed files with 33 additions and 13 deletions
|
|
@ -28,6 +28,24 @@ describe('dom', function() {
|
|||
expect(dom.toString()).toContain('<h2>sub-heading</h2>');
|
||||
});
|
||||
|
||||
it('should properly number nested headings', function() {
|
||||
dom.h('heading', function() {
|
||||
dom.h('heading2', function() {
|
||||
this.html('<h1>heading3</h1>');
|
||||
});
|
||||
});
|
||||
dom.h('other1', function() {
|
||||
this.html('<h1>other2</h1>');
|
||||
});
|
||||
|
||||
expect(dom.toString()).toContain('<h1 id="heading">heading</h1>');
|
||||
expect(dom.toString()).toContain('<h2 id="heading2">heading2</h2>');
|
||||
expect(dom.toString()).toContain('<h3>heading3</h3>');
|
||||
|
||||
expect(dom.toString()).toContain('<h1 id="other1">other1</h1>');
|
||||
expect(dom.toString()).toContain('<h2>other2</h2>');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ describe('ngdoc', function() {
|
|||
describe('Doc', function() {
|
||||
describe('metadata', function() {
|
||||
|
||||
it('should find keywords', function() {
|
||||
it('should find keywords and filter ignored words', function() {
|
||||
expect(new Doc('\nHello: World! @ignore. $abc').keywords()).toEqual('$abc hello world');
|
||||
expect(new Doc('The `ng:class-odd` and').keywords()).toEqual('and ng:class-odd the');
|
||||
expect(new Doc('The `ng:class-odd` and').keywords()).toEqual('ng:class-odd');
|
||||
});
|
||||
|
||||
it('should get property and methods', function() {
|
||||
|
|
@ -147,7 +147,7 @@ describe('ngdoc', function() {
|
|||
|
||||
it('should replace text between two <pre></pre> tags', function() {
|
||||
expect(new Doc().markdown('<pre>x</pre>\n# One\n<pre>b</pre>')).
|
||||
toMatch('</pre>\n\n<h1>One</h1>\n\n<pre');
|
||||
toMatch('</pre>\n\n<h1 id="one">One</h1>\n\n<pre');
|
||||
});
|
||||
|
||||
it('should ignore nested doc widgets', function() {
|
||||
|
|
@ -405,7 +405,7 @@ describe('ngdoc', function() {
|
|||
expect(doc.description).
|
||||
toBe('<p>foo \n' +
|
||||
'<pre class="prettyprint linenums">abc</pre>\n\n' +
|
||||
'<h1>bah</h1>\n\n' +
|
||||
'<h1 id="bah">bah</h1>\n\n' +
|
||||
'<p>foo \n' +
|
||||
'<pre class="prettyprint linenums">cba</pre>');
|
||||
|
||||
|
|
@ -499,7 +499,7 @@ describe('ngdoc', function() {
|
|||
var doc = new Doc('@ngdoc overview\n@name angular\n@description\n#heading\ntext');
|
||||
doc.parse();
|
||||
expect(doc.html()).toContain('text');
|
||||
expect(doc.html()).toContain('<h2>heading</h2>');
|
||||
expect(doc.html()).toContain('<h2 id="heading">heading</h2>');
|
||||
expect(doc.html()).not.toContain('Description');
|
||||
});
|
||||
});
|
||||
|
|
@ -511,7 +511,7 @@ describe('ngdoc', function() {
|
|||
ngdoc:'function',
|
||||
name:'some.name',
|
||||
param: [
|
||||
{name:'a', optional: true},
|
||||
{name:'a', type: 'string', optional: true},
|
||||
{name:'b', type: 'someType', optional: true, 'default': '"xxx"'},
|
||||
{name:'c', type: 'string', description: 'param desc'}
|
||||
],
|
||||
|
|
@ -520,7 +520,7 @@ describe('ngdoc', function() {
|
|||
doc.html_usage_function(dom);
|
||||
expect(dom).toContain('name([a][, b], c)'); //TODO(i) the comma position here is lame
|
||||
expect(dom).toContain('param desc');
|
||||
expect(dom).toContain('(optional="xxx")');
|
||||
expect(dom).toContain('(optional)');
|
||||
expect(dom).toContain('return desc');
|
||||
});
|
||||
});
|
||||
|
|
@ -531,8 +531,8 @@ describe('ngdoc', function() {
|
|||
ngdoc:'formatter',
|
||||
shortName:'myFilter',
|
||||
param: [
|
||||
{name:'a'},
|
||||
{name:'b'}
|
||||
{name:'a', type:'string'},
|
||||
{name:'b', type:'string'}
|
||||
]
|
||||
});
|
||||
doc.html_usage_filter(dom);
|
||||
|
|
@ -546,6 +546,7 @@ describe('ngdoc', function() {
|
|||
var doc = new Doc({
|
||||
ngdoc:'property',
|
||||
name:'myProp',
|
||||
type:'string',
|
||||
returns:{type: 'type', description: 'description'}
|
||||
});
|
||||
doc.html_usage_property(dom);
|
||||
|
|
|
|||
|
|
@ -43,8 +43,9 @@ DOM.prototype = {
|
|||
var headingDepth = this.headingDepth;
|
||||
for ( var i = 10; i > 0; --i) {
|
||||
html = html
|
||||
.replace(new RegExp('(<\/?h)' + i + '(>)', 'gm'), function(all, start, end){
|
||||
return start + (i + headingDepth) + end;
|
||||
.replace(new RegExp('<h' + i + '(.*?)>([\\s\\S]+)<\/h' + i +'>', 'gm'), function(_, attrs, content){
|
||||
var tag = 'h' + (i + headingDepth);
|
||||
return '<' + tag + attrs + '>' + content + '</' + tag + '>';
|
||||
});
|
||||
}
|
||||
this.out.push(html);
|
||||
|
|
|
|||
|
|
@ -678,7 +678,6 @@ without
|
|||
won't
|
||||
wont
|
||||
words
|
||||
world
|
||||
would
|
||||
wouldn't
|
||||
wouldnt
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ var NEW_LINE = /\n\r?/;
|
|||
var globalID = 0;
|
||||
var fs = require('fs');
|
||||
var fspath = require('path');
|
||||
var markdown = new Showdown.converter({ extensions : ['table'] });
|
||||
|
||||
exports.trim = trim;
|
||||
exports.metadata = metadata;
|
||||
|
|
@ -216,7 +217,7 @@ Doc.prototype = {
|
|||
});
|
||||
});
|
||||
text = parts.join('');
|
||||
text = new Showdown.converter({ extensions : ['table'] }).makeHtml(text);
|
||||
text = markdown.makeHtml(text);
|
||||
text = text.replace(/(?:<p>)?(REPLACEME\d+)(?:<\/p>)?/g, function(_, id) {
|
||||
return placeholderMap[id];
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue