From 258cae83dc1a03b6b878a7b4236c499288cd2624 Mon Sep 17 00:00:00 2001 From: Matias Niemelä Date: Mon, 8 Jul 2013 21:58:14 -0400 Subject: chore(ngdocs): replace showdown.js with marked.js --- docs/component-spec/annotationsSpec.js | 2 +- docs/components/angular-bootstrap/bootstrap.js | 12 +++- docs/spec/ngdocSpec.js | 79 +++++++++++++------------- docs/src/gen-docs.js | 3 +- docs/src/ngdoc.js | 10 ++-- docs/src/templates/index.html | 2 +- 6 files changed, 58 insertions(+), 50 deletions(-) (limited to 'docs') diff --git a/docs/component-spec/annotationsSpec.js b/docs/component-spec/annotationsSpec.js index 29cb9c53..321118ad 100644 --- a/docs/component-spec/annotationsSpec.js +++ b/docs/component-spec/annotationsSpec.js @@ -57,7 +57,7 @@ describe('Docs Annotations', function() { $scope.$apply(); element.triggerHandler('click'); expect(popoverElement.title()).toBe('#title_text'); - expect(popoverElement.content()).toBe('
short
med
long\nline
fn with optional arguments
short
\nmed
\nlong\nline
\nfn with optional arguments
\ntext bold.
text bold.
\n\n' +
'<b>angular</b>.k\n' +
'\n' +
- ' asdf x');
+ ' asdf x\n');
});
it('should wrap everything inside a container tag', function() {
var doc = new Doc('@name superman').parse();
var content = doc.markdown('hello');
- expect(content).toMatch('hello
hello
\nhello
hello
\nx\n# One\n
b')). - toMatch('\n\n
\nOne
\n\n' + + 'before\n\n' + '')).toEqual( - '' + - '\ngit bla bla\n\n' + - '')).toEqual( + '\ngit bla bla\n\n' + + ''); }); it('should support nested @link annotations with or without description', function() { @@ -491,7 +490,7 @@ describe('ngdoc', function() { it('should not remove {{}}', function() { var doc = new Doc('@name a\n@example text {{ abc }}'); doc.parse(); - expect(doc.example).toEqual('before
\n' + + ''); }); it('should unindent text before processing based on the second line', function() { @@ -190,10 +190,10 @@ describe('ngdoc', function() { ' fourth line\n\n' + ' fifth line')). toMatch('before
\n\n' + '\n' + + '\n' + 'git bla bla\n' + - '\n' + - ''); + 'first line\n' + - 'second line
\n\n' + + 'second line\n' + '\n\n' + - 'third line\n' + - ' fourth line\nfifth line
'); + ' fourth line\n' + + 'fifth line
\n'); }); it('should unindent text before processing based on the first line', function() { @@ -202,11 +202,11 @@ describe('ngdoc', function() { ' third line\n' + ' fourth line\n\n' + ' fifth line')). - toMatch('first line
\n\n' + + toMatch(''); }); @@ -304,7 +304,7 @@ describe('ngdoc', function() { name : 'number', optional: false, 'default' : undefined, - description : 'first line
\n' + '\n\n' + - 'second line\n' + 'third line\n' + - ' fourth line\nfifth line
'); + ' fourth line\n' + + 'fifth line
\n' }]); + description : 'Number \nto format.
' }]); }); it('should parse with default and optional', function() { @@ -315,7 +315,7 @@ describe('ngdoc', function() { name : 'fractionSize', optional: true, 'default' : '2', - description : 'Number \nto format.
\n' }]); + description : 'desc
' }]); }); }); @@ -325,8 +325,8 @@ describe('ngdoc', function() { doc.ngdoc = 'service'; doc.parse(); expect(doc.requires).toEqual([ - {name:'$service', text:'desc
\n'}, - {name:'$another', text:'for \n
A'}]); + {name:'$service', text:'for
B'}, + {name:'$another', text:'for \n
\nA'}]); expect(doc.html()).toContain('$service'); expect(doc.html()).toContain('$another'); expect(doc.html()).toContain('for
\nBfor \n
'); @@ -378,7 +378,7 @@ describe('ngdoc', function() { var doc = new Doc("@name a\n@property {string} name desc rip tion"); doc.parse(); expect(doc.properties[0].name).toEqual('name'); - expect(doc.properties[0].description).toEqual('A'); + expect(doc.properties[0].description).toEqual('desc rip tion
'); }); it('should parse @property with type and description both', function() { @@ -386,7 +386,7 @@ describe('ngdoc', function() { doc.parse(); expect(doc.properties[0].name).toEqual('name'); expect(doc.properties[0].type).toEqual('bool'); - expect(doc.properties[0].description).toEqual('desc rip tion
\n'); + expect(doc.properties[0].description).toEqual('desc rip tion
'); }); }); @@ -409,26 +409,26 @@ describe('ngdoc', function() { it('should parse @returns with type and description', function() { var doc = new Doc("@name a\n@returns {string} descrip tion"); doc.parse(); - expect(doc.returns).toEqual({type: 'string', description: 'desc rip tion
\n'}); + expect(doc.returns).toEqual({type: 'string', description: 'descrip tion
'}); }); it('should parse @returns with complex type and description', function() { var doc = new Doc("@name a\n@returns {function(string, number=)} description"); doc.parse(); - expect(doc.returns).toEqual({type: 'function(string, number=)', description: 'descrip tion
\n'}); + expect(doc.returns).toEqual({type: 'function(string, number=)', description: 'description
'}); }); it('should transform description of @returns with markdown', function() { var doc = new Doc("@name a\n@returns {string} descrip *tion*"); doc.parse(); - expect(doc.returns).toEqual({type: 'string', description: 'description
\n'}); + expect(doc.returns).toEqual({type: 'string', description: 'descrip tion
'}); }); it('should support multiline content', function() { var doc = new Doc("@name a\n@returns {string} description\n new line\n another line"); doc.parse(); expect(doc.returns). - toEqual({type: 'string', description: 'descrip tion
\n'}); + toEqual({type: 'string', description: 'description\nnew line\nanother line
'}); }); }); @@ -437,7 +437,7 @@ describe('ngdoc', function() { var doc = new Doc("@name a\n@descriptiondescription\nnew line\nanother line
\nabc"); doc.parse(); expect(doc.description). - toBe(''); + toBe('<b>abc</b>'); }); it('should support multiple pre blocks', function() { @@ -445,11 +445,10 @@ describe('ngdoc', function() { doc.parse(); expect(doc.description). toBe('<b>abc</b>\n'); - + 'foo \n' + - '
abc\n\n' + - 'bah
\n\n' + + 'abc\n' + + 'bah
\n' + 'foo \n' + - '
cbacba\n'); + expect(doc.example).toEqual('text {{ abc }}
'); }); }); @@ -511,11 +510,11 @@ describe('ngdoc', function() { expect(doc.html()).toContain('text {{ abc }}
\nMethod\'s
\n' + 'this' + '\n'); expect(doc.html()).toContain('' + - '' + 'I am self.
' + + 'I am self.
\n' + 'Method\'s
\n' + - 'this'); + 'I am self.
'); }); }); @@ -542,7 +541,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('I am self.
\nheading
'); + expect(doc.html()).toContain('heading
'); expect(doc.html()).not.toContain('Description'); }); }); diff --git a/docs/src/gen-docs.js b/docs/src/gen-docs.js index 2e711ab3..10b01385 100755 --- a/docs/src/gen-docs.js +++ b/docs/src/gen-docs.js @@ -83,8 +83,7 @@ function writeTheRest(writesFuture) { writesFuture.push(writer.copyDir('components/components-font-awesome/font', 'components/font-awesome/font')); writesFuture.push(writer.copyDir('components/bootstrap', 'components/bootstrap')); - writesFuture.push(writer.copy('node_modules/showdown/src/showdown.js', 'components/showdown.js')); - writesFuture.push(writer.copy('node_modules/showdown/compressed/showdown.js', 'components/showdown.min.js')); + writesFuture.push(writer.copy('node_modules/marked/lib/marked.js', 'components/marked.js')); writesFuture.push(writer.copy('components/lunr.js/lunr.js', 'components/lunr.js')); writesFuture.push(writer.copy('components/lunr.js/lunr.min.js', 'components/lunr.min.js')); writesFuture.push(writer.copy('components/jquery/jquery.js', 'components/jquery.js')); diff --git a/docs/src/ngdoc.js b/docs/src/ngdoc.js index 4ad478f4..394510c5 100644 --- a/docs/src/ngdoc.js +++ b/docs/src/ngdoc.js @@ -1,8 +1,6 @@ /** * All parsing/transformation code goes here. All code here should be sync to ease testing. */ - -var Showdown = require('showdown'); var DOM = require('./dom.js').DOM; var htmlEscape = require('./dom.js').htmlEscape; var Example = require('./example.js').Example; @@ -10,10 +8,14 @@ var NEW_LINE = /\n\r?/; var globalID = 0; var fs = require('fs'); var fspath = require('path'); -var markdown = new Showdown.converter({ extensions : ['table'] }); var shell = require('shelljs'); var gruntUtil = require('../../lib/grunt/utils.js'); var errorsJson; +var marked = require('marked'); +marked.setOptions({ + gfm: true, + tables: true +}); var lookupMinerrMsg = function (doc) { var code, namespace; @@ -289,7 +291,7 @@ Doc.prototype = { pageClassName = pageClassName || prepareClassName(this.name || 'docs') + suffix; text = '' + - markdown.makeHtml(text) + + marked(text) + ''; text = text.replace(/(?:)?(REPLACEME\d+)(?:<\/p>)?/g, function(_, id) { return placeholderMap[id]; diff --git a/docs/src/templates/index.html b/docs/src/templates/index.html index 65e26c99..82a5c87e 100644 --- a/docs/src/templates/index.html +++ b/docs/src/templates/index.html @@ -47,7 +47,7 @@ addTag('script', {src: 'components/angular-bootstrap-prettify.js' }, sync); addTag('script', {src: 'components/google-code-prettify.js' }, sync); addTag('script', {src: 'components/' + (debug ? 'lunr.js' : 'lunr.min.js') }, sync); - addTag('script', {src: 'components/' + (debug ? 'showdown.js' : 'showdown.min.js') }, sync); + addTag('script', {src: 'components/marked.js' }, sync); addTag('script', {src: 'docs-data.js'}, sync); addTag('script', {src: 'js/docs.js'}, sync); -- cgit v1.2.3