Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 258cae8

Browse files
matskoIgorMinar
authored andcommitted
chore(ngdocs): replace showdown.js with marked.js
1 parent ab18914 commit 258cae8

File tree

10 files changed

+62
-54
lines changed

10 files changed

+62
-54
lines changed

docs/component-spec/annotationsSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('Docs Annotations', function() {
5757
$scope.$apply();
5858
element.triggerHandler('click');
5959
expect(popoverElement.title()).toBe('#title_text');
60-
expect(popoverElement.content()).toBe('<h1 id="heading">heading</h1>');
60+
expect(popoverElement.content()).toBe('<h1>heading</h1>\n');
6161
}));
6262

6363
});

docs/components/angular-bootstrap/bootstrap.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ var popoverElement = function() {
257257

258258
content : function(value) {
259259
if(value && value.length > 0) {
260-
value = new Showdown.converter().makeHtml(value);
260+
value = marked(value);
261261
}
262262
return this.contentElement.html(value);
263263
},
@@ -380,4 +380,12 @@ directive.foldout = ['$http', '$animator','$window', function($http, $animator,
380380
}
381381
}];
382382

383-
angular.module('bootstrap', []).directive(directive).factory('popoverElement', popoverElement);
383+
angular.module('bootstrap', [])
384+
.directive(directive)
385+
.factory('popoverElement', popoverElement)
386+
.run(function() {
387+
marked.setOptions({
388+
gfm: true,
389+
tables: true
390+
});
391+
});

docs/spec/ngdocSpec.js

+39-40
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ describe('ngdoc', function() {
5959
'@param {function(number, string=)} d fn with optional arguments');
6060
doc.parse();
6161
expect(doc.param).toEqual([
62-
{name:'a', description:'<div class="a-page"><p>short</p></div>', type:'*', optional:false, 'default':undefined},
63-
{name:'b', description:'<div class="a-page"><p>med</p></div>', type:'Type', optional:false, 'default':undefined},
64-
{name:'c', description:'<div class="a-page"><p>long\nline</p></div>', type:'Class', optional:true, 'default':'2'},
65-
{name:'d', description:'<div class="a-page"><p>fn with optional arguments</p></div>',
62+
{name:'a', description:'<div class="a-page"><p>short</p>\n</div>', type:'*', optional:false, 'default':undefined},
63+
{name:'b', description:'<div class="a-page"><p>med</p>\n</div>', type:'Type', optional:false, 'default':undefined},
64+
{name:'c', description:'<div class="a-page"><p>long\nline</p>\n</div>', type:'Class', optional:true, 'default':'2'},
65+
{name:'d', description:'<div class="a-page"><p>fn with optional arguments</p>\n</div>',
6666
type: 'function(number, string=)', optional: false, 'default':undefined}
6767
]);
6868
});
@@ -72,7 +72,7 @@ describe('ngdoc', function() {
7272
doc.parse();
7373
expect(doc.returns).toEqual({
7474
type: 'Type',
75-
description: '<div class="a-page"><p>text <em>bold</em>.</p></div>'
75+
description: '<div class="a-page"><p>text <em>bold</em>.</p>\n</div>'
7676
});
7777
});
7878

@@ -142,26 +142,26 @@ describe('ngdoc', function() {
142142
'<pre class="prettyprint linenums">\n' +
143143
'&lt;b&gt;angular&lt;/b&gt;.k\n' +
144144
'</pre>\n' +
145-
' asdf x</p></div>');
145+
' asdf x</p>\n</div>');
146146
});
147147

148148
it('should wrap everything inside a container tag', function() {
149149
var doc = new Doc('@name superman').parse();
150150
var content = doc.markdown('hello');
151151

152-
expect(content).toMatch('<div class="superman-page"><p>hello</p></div>');
152+
expect(content).toMatch('<div class="superman-page"><p>hello</p>\n</div>');
153153
});
154154

155155
it('should use the content before a colon as the name prefix for the className of the tag container', function() {
156156
var doc = new Doc('@name super: man').parse();
157157
var content = doc.markdown('hello');
158158

159-
expect(content).toMatch('<div class="super-page super-man-page"><p>hello</p></div>');
159+
expect(content).toMatch('<div class="super-page super-man-page"><p>hello</p>\n</div>');
160160
});
161161

162162
it('should replace text between two <pre></pre> tags', function() {
163163
expect(new Doc().markdown('<pre>x</pre>\n# One\n<pre>b</pre>')).
164-
toMatch('</pre>\n\n<h1 id="one">One</h1>\n\n<pre');
164+
toMatch('</pre>\n<h1>One</h1>\n<pre');
165165
});
166166

167167
it('should replace inline variable type hints', function() {
@@ -171,16 +171,16 @@ describe('ngdoc', function() {
171171

172172
it('should ignore nested doc widgets', function() {
173173
expect(new Doc().markdown(
174-
'before<div class="tabbable">\n' +
174+
'before\n<div class="tabbable">\n' +
175175
'<div class="tab-pane well" id="git-mac" ng:model="Git on Mac/Linux">' +
176-
'\ngit bla bla\n</doc:tutorial-instruction>\n' +
177-
'</doc:tutorial-instructions>')).toEqual(
176+
'\ngit bla bla\n</div>\n' +
177+
'</div>')).toEqual(
178178

179-
'<div class="docs-page"><p>before<div class="tabbable">\n' +
179+
'<div class="docs-page"><p>before</p>\n<div class="tabbable">\n' +
180180
'<div class="tab-pane well" id="git-mac" ng:model="Git on Mac/Linux">\n' +
181181
'git bla bla\n' +
182-
'</doc:tutorial-instruction>\n' +
183-
'</doc:tutorial-instructions></p></div>');
182+
'</div>\n' +
183+
'</div></div>');
184184
});
185185

186186
it('should unindent text before processing based on the second line', function() {
@@ -190,10 +190,10 @@ describe('ngdoc', function() {
190190
' fourth line\n\n' +
191191
' fifth line')).
192192
toMatch('<p>first line\n' +
193-
'second line</p>\n\n' +
193+
'second line</p>\n' +
194194
'<pre><code>third line\n' +
195-
' fourth line\n</code></pre>\n\n' +
196-
'<p>fifth line</p>');
195+
' fourth line</code></pre>\n' +
196+
'<p>fifth line</p>\n');
197197
});
198198

199199
it('should unindent text before processing based on the first line', function() {
@@ -202,11 +202,11 @@ describe('ngdoc', function() {
202202
' third line\n' +
203203
' fourth line\n\n' +
204204
' fifth line')).
205-
toMatch('<p>first line</p>\n\n' +
205+
toMatch('<div class="docs-page"><p>first line</p>\n' +
206206
'<pre><code>second line\n' +
207207
'third line\n' +
208-
' fourth line\n</code></pre>\n\n' +
209-
'<p>fifth line</p>');
208+
' fourth line</code></pre>\n' +
209+
'<p>fifth line</p>\n</div>');
210210
});
211211

212212

@@ -304,7 +304,7 @@ describe('ngdoc', function() {
304304
name : 'number',
305305
optional: false,
306306
'default' : undefined,
307-
description : '<div class="a-page"><p>Number \nto format.</p></div>' }]);
307+
description : '<div class="a-page"><p>Number \nto format.</p>\n</div>' }]);
308308
});
309309

310310
it('should parse with default and optional', function() {
@@ -315,7 +315,7 @@ describe('ngdoc', function() {
315315
name : 'fractionSize',
316316
optional: true,
317317
'default' : '2',
318-
description : '<div class="a-page"><p>desc</p></div>' }]);
318+
description : '<div class="a-page"><p>desc</p>\n</div>' }]);
319319
});
320320
});
321321

@@ -325,8 +325,8 @@ describe('ngdoc', function() {
325325
doc.ngdoc = 'service';
326326
doc.parse();
327327
expect(doc.requires).toEqual([
328-
{name:'$service', text:'<div class="a-page"><p>for \n<code>A</code></p></div>'},
329-
{name:'$another', text:'<div class="a-page"><p>for <code>B</code></p></div>'}]);
328+
{name:'$service', text:'<div class="a-page"><p>for \n<code>A</code></p>\n</div>'},
329+
{name:'$another', text:'<div class="a-page"><p>for <code>B</code></p>\n</div>'}]);
330330
expect(doc.html()).toContain('<a href="api/ng.$service">$service</a>');
331331
expect(doc.html()).toContain('<a href="api/ng.$another">$another</a>');
332332
expect(doc.html()).toContain('<p>for \n<code>A</code></p>');
@@ -378,15 +378,15 @@ describe('ngdoc', function() {
378378
var doc = new Doc("@name a\n@property {string} name desc rip tion");
379379
doc.parse();
380380
expect(doc.properties[0].name).toEqual('name');
381-
expect(doc.properties[0].description).toEqual('<div class="a-page"><p>desc rip tion</p></div>');
381+
expect(doc.properties[0].description).toEqual('<div class="a-page"><p>desc rip tion</p>\n</div>');
382382
});
383383

384384
it('should parse @property with type and description both', function() {
385385
var doc = new Doc("@name a\n@property {bool} name desc rip tion");
386386
doc.parse();
387387
expect(doc.properties[0].name).toEqual('name');
388388
expect(doc.properties[0].type).toEqual('bool');
389-
expect(doc.properties[0].description).toEqual('<div class="a-page"><p>desc rip tion</p></div>');
389+
expect(doc.properties[0].description).toEqual('<div class="a-page"><p>desc rip tion</p>\n</div>');
390390
});
391391

392392
});
@@ -409,26 +409,26 @@ describe('ngdoc', function() {
409409
it('should parse @returns with type and description', function() {
410410
var doc = new Doc("@name a\n@returns {string} descrip tion");
411411
doc.parse();
412-
expect(doc.returns).toEqual({type: 'string', description: '<div class="a-page"><p>descrip tion</p></div>'});
412+
expect(doc.returns).toEqual({type: 'string', description: '<div class="a-page"><p>descrip tion</p>\n</div>'});
413413
});
414414

415415
it('should parse @returns with complex type and description', function() {
416416
var doc = new Doc("@name a\n@returns {function(string, number=)} description");
417417
doc.parse();
418-
expect(doc.returns).toEqual({type: 'function(string, number=)', description: '<div class="a-page"><p>description</p></div>'});
418+
expect(doc.returns).toEqual({type: 'function(string, number=)', description: '<div class="a-page"><p>description</p>\n</div>'});
419419
});
420420

421421
it('should transform description of @returns with markdown', function() {
422422
var doc = new Doc("@name a\n@returns {string} descrip *tion*");
423423
doc.parse();
424-
expect(doc.returns).toEqual({type: 'string', description: '<div class="a-page"><p>descrip <em>tion</em></p></div>'});
424+
expect(doc.returns).toEqual({type: 'string', description: '<div class="a-page"><p>descrip <em>tion</em></p>\n</div>'});
425425
});
426426

427427
it('should support multiline content', function() {
428428
var doc = new Doc("@name a\n@returns {string} description\n new line\n another line");
429429
doc.parse();
430430
expect(doc.returns).
431-
toEqual({type: 'string', description: '<div class="a-page"><p>description\nnew line\nanother line</p></div>'});
431+
toEqual({type: 'string', description: '<div class="a-page"><p>description\nnew line\nanother line</p>\n</div>'});
432432
});
433433
});
434434

@@ -437,19 +437,18 @@ describe('ngdoc', function() {
437437
var doc = new Doc("@name a\n@description <pre><b>abc</b></pre>");
438438
doc.parse();
439439
expect(doc.description).
440-
toBe('<div class="a-page"><pre class="prettyprint linenums">&lt;b&gt;abc&lt;/b&gt;</pre></div>');
440+
toBe('<div class="a-page"><pre class="prettyprint linenums">&lt;b&gt;abc&lt;/b&gt;</pre>\n</div>');
441441
});
442442

443443
it('should support multiple pre blocks', function() {
444444
var doc = new Doc("@name a\n@description foo \n<pre>abc</pre>\n#bah\nfoo \n<pre>cba</pre>");
445445
doc.parse();
446446
expect(doc.description).
447447
toBe('<div class="a-page"><p>foo \n' +
448-
'<pre class="prettyprint linenums">abc</pre>\n\n' +
449-
'<h1 id="bah">bah</h1>\n\n' +
448+
'<pre class="prettyprint linenums">abc</pre>\n' +
449+
'<h1>bah</h1>\n' +
450450
'<p>foo \n' +
451-
'<pre class="prettyprint linenums">cba</pre></div>');
452-
451+
'<pre class="prettyprint linenums">cba</pre>\n</div>');
453452
});
454453

455454
it('should support nested @link annotations with or without description', function() {
@@ -491,7 +490,7 @@ describe('ngdoc', function() {
491490
it('should not remove {{}}', function() {
492491
var doc = new Doc('@name a\n@example text {{ abc }}');
493492
doc.parse();
494-
expect(doc.example).toEqual('<div class="a-page"><p>text {{ abc }}</p></div>');
493+
expect(doc.example).toEqual('<div class="a-page"><p>text {{ abc }}</p>\n</div>');
495494
});
496495
});
497496

@@ -511,11 +510,11 @@ describe('ngdoc', function() {
511510
expect(doc.html()).toContain('<h3>Method\'s <code>this</code></h3>\n' +
512511
'<div>' +
513512
'<div class="a-page">' +
514-
'<p>I am self.</p>' +
513+
'<p>I am self.</p>\n' +
515514
'</div>' +
516515
'</div>\n');
517516
expect(doc.html()).toContain('<h3>Method\'s <code>this</code></h3>\n' +
518-
'<div><div class="a-page"><p>I am self.</p></div></div>');
517+
'<div><div class="a-page"><p>I am self.</p>\n</div></div>');
519518
});
520519
});
521520

@@ -542,7 +541,7 @@ describe('ngdoc', function() {
542541
var doc = new Doc('@ngdoc overview\n@name angular\n@description\n#heading\ntext');
543542
doc.parse();
544543
expect(doc.html()).toContain('text');
545-
expect(doc.html()).toContain('<h2 id="heading">heading</h2>');
544+
expect(doc.html()).toContain('<h2>heading</h2>');
546545
expect(doc.html()).not.toContain('Description');
547546
});
548547
});

docs/src/gen-docs.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ function writeTheRest(writesFuture) {
8383
writesFuture.push(writer.copyDir('components/components-font-awesome/font', 'components/font-awesome/font'));
8484
writesFuture.push(writer.copyDir('components/bootstrap', 'components/bootstrap'));
8585

86-
writesFuture.push(writer.copy('node_modules/showdown/src/showdown.js', 'components/showdown.js'));
87-
writesFuture.push(writer.copy('node_modules/showdown/compressed/showdown.js', 'components/showdown.min.js'));
86+
writesFuture.push(writer.copy('node_modules/marked/lib/marked.js', 'components/marked.js'));
8887
writesFuture.push(writer.copy('components/lunr.js/lunr.js', 'components/lunr.js'));
8988
writesFuture.push(writer.copy('components/lunr.js/lunr.min.js', 'components/lunr.min.js'));
9089
writesFuture.push(writer.copy('components/jquery/jquery.js', 'components/jquery.js'));

docs/src/ngdoc.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
/**
22
* All parsing/transformation code goes here. All code here should be sync to ease testing.
33
*/
4-
5-
var Showdown = require('showdown');
64
var DOM = require('./dom.js').DOM;
75
var htmlEscape = require('./dom.js').htmlEscape;
86
var Example = require('./example.js').Example;
97
var NEW_LINE = /\n\r?/;
108
var globalID = 0;
119
var fs = require('fs');
1210
var fspath = require('path');
13-
var markdown = new Showdown.converter({ extensions : ['table'] });
1411
var shell = require('shelljs');
1512
var gruntUtil = require('../../lib/grunt/utils.js');
1613
var errorsJson;
14+
var marked = require('marked');
15+
marked.setOptions({
16+
gfm: true,
17+
tables: true
18+
});
1719

1820
var lookupMinerrMsg = function (doc) {
1921
var code, namespace;
@@ -289,7 +291,7 @@ Doc.prototype = {
289291
pageClassName = pageClassName || prepareClassName(this.name || 'docs') + suffix;
290292

291293
text = '<div class="' + pageClassName + '">' +
292-
markdown.makeHtml(text) +
294+
marked(text) +
293295
'</div>';
294296
text = text.replace(/(?:<p>)?(REPLACEME\d+)(?:<\/p>)?/g, function(_, id) {
295297
return placeholderMap[id];

docs/src/templates/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
addTag('script', {src: 'components/angular-bootstrap-prettify.js' }, sync);
4848
addTag('script', {src: 'components/google-code-prettify.js' }, sync);
4949
addTag('script', {src: 'components/' + (debug ? 'lunr.js' : 'lunr.min.js') }, sync);
50-
addTag('script', {src: 'components/' + (debug ? 'showdown.js' : 'showdown.min.js') }, sync);
50+
addTag('script', {src: 'components/marked.js' }, sync);
5151
addTag('script', {src: 'docs-data.js'}, sync);
5252
addTag('script', {src: 'js/docs.js'}, sync);
5353

karma-docs.conf.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = function(config) {
1818

1919
'build/docs/components/lunr.js',
2020
'build/docs/components/google-code-prettify.js',
21-
'build/docs/components/showdown.js',
21+
'build/docs/components/marked.js',
2222

2323
'build/docs/components/angular-bootstrap.js',
2424
'build/docs/components/angular-bootstrap-prettify.js',

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"karma-sauce-launcher": "~0.0.4",
2626
"karma-script-launcher": "~0.0.1",
2727
"yaml-js": "0.0.5",
28-
"showdown": "0.3.1",
28+
"marked": "~0.2.9",
2929
"rewire": "1.1.3",
3030
"grunt-contrib-jasmine-node": "~0.1.1",
3131
"grunt-parallel": "~0.2.0",

src/ng/animator.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* Below is a more detailed breakdown of the supported callback events provided by pre-exisitng ng directives:
1717
*
1818
* | Directive | Supported Animations |
19-
* |========================================================== |====================================================|
19+
* |---------------------------------------------------------- |----------------------------------------------------|
2020
* | {@link ng.directive:ngRepeat#animations ngRepeat} | enter, leave and move |
2121
* | {@link ngRoute.directive:ngView#animations ngView} | enter and leave |
2222
* | {@link ng.directive:ngInclude#animations ngInclude} | enter and leave |

src/ng/directive/ngRepeat.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Special properties are exposed on the local scope of each template instance, including:
1313
*
1414
* | Variable | Type | Details |
15-
* |===========|=================|=============================================================================|
15+
* |-----------|-----------------|-----------------------------------------------------------------------------|
1616
* | `$index` | {@type number} | iterator offset of the repeated element (0..length-1) |
1717
* | `$first` | {@type boolean} | true if the repeated element is first in the iterator. |
1818
* | `$middle` | {@type boolean} | true if the repeated element is between the first and last in the iterator. |

0 commit comments

Comments
 (0)